function fncSr = fncSpeedRef(param,r,v,robStateLen) sp = [1, 2]; % 1 = x; 2 = y if (length(param) == 4) % 'xsin' / 'xcos' strSinOcos = strcat(sprintf("%s", param(2:length(param)))); if (param(1) == 'x') strSfx = strcat(sprintf("%i*%s(%i*t)",r,strSinOcos,v)); strSfy = strcat(sprintf("%i",r)); % 'ysin' / 'ycos' elseif (param(1) == 'y') strSfx = strcat(sprintf("%i",r)); strSfy = strcat(sprintf("%i*%s(%i*t)",r,strSinOcos,v)); endif elseif (param(1) == 'c') if(param(2) == 'c') %'circle' strSfx = strcat(sprintf("%i*cos(%i*t)",r,v)); strSfy = strcat(sprintf("%i*sin(%i*t)",r,v)); else strSfx = strcat(sprintf("%i*sin(%i*t)",r,v)); strSfy = strcat(sprintf("%i*cos(%i*t)",r,v)); endif elseif (param(1) == 's') strSinOcos = strcat(sprintf("%s", param(3:end))); if (length(param) > 1) if (param(2) == 'y') strSfx = strcat(sprintf("%i*%s(%i*t)",r,strSinOcos,v)); strSfy = strcat(sprintf("%i",0)); % 'ysin' / 'ycos' else %if (param(2) == 'x') strSfx = strcat(sprintf("%i",0)); strSfy = strcat(sprintf("%i*%s(%i*t)",r,strSinOcos,v)); endif else strSfx = strcat(sprintf("%i",r)); strSfy = strcat(sprintf("%i",v)); endif else printf("Karepmu opo ? \n\n bukak fungsi speedRef sek diwoco komen e \n\n"); endif if (robStateLen==2) strAll = strcat("fncSr = @(t) [",strSfx, ";\ ", strSfy, "];"); elseif(robStateLen==3) strAll = strcat("fncSr = @(t) [",strSfx, ";\ ", strSfy, ";\ 0];"); else printf("ERROR REFSPEED NOT SUPPORT!!"); endif %% printf(strAll) eval(strAll); %% spx = sfx(t); %% spy = sfy(t); endfunction