as I said lately about piecewise function , i have problem ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i want to model part 2 of a paper i attach it as I said before ( i want define a piecewise function like as picture below that t is variable and we have f(t)= piecewise function and i want to plot it and do fourier illustration of this function and use fft function on it ant plot them) i do it with the help of some of mathworks member to stage of formation of piecwise and plot it on matlab
and after that i couldn't continue the procedure of my program . and had error.
please give me some information ... thanks
L=input(' define L (lenght of wagon -m) : ');
V=input(' define V (speed of train -km/h) : ');
X1=input(' define X1(distance betwean 2 wagon -m) : ');
X2=input(' define X2(distance betwean 2 middle wheels -m): ');
X=input(' define X (distance betwean 2 near wheels -m) : ');
W=input(' define W (total weight of wagon and passenger -ton) : ');
V=V*1000/3600;disp([' *** V : (speed of train)= ',num2str(V),' m/s'])
disp([' *** L : (lenght of wagon) = ',num2str(L),' m'])
disp([' *** X1: (distance betwean 2 wagon) = ',num2str(X1),' m'])
disp([' *** X2: (distance betwean 2 middle wheels) = ',num2str(X2),' m'])
disp([' *** X : (distance betwean 2 near wheels) = ',num2str(X),' m'])
disp([' *** W : (total weight of wagon) = ',num2str(W),' ton'])
F1=W*9.81/8;
disp([' *** F1: (force of 1 wheel) = ',num2str(F1),' kN'])
t1=X/V;t2=(X+X2)/V;t3=(2*X+X2)/V;t4=(2*X+X2+(L-X2-2*X)+X1)/V;
disp([' *** F1 = ',num2str(F1),' kN'])
disp([' * t1 = ',num2str(t1),' s'])
disp([' * t2 = ',num2str(t2),' s'])
disp([' * t3 = ',num2str(t3),' s'])
disp([' * t4 = ',num2str(t4),' s'])
t1 =0.0001*round(10000*t1);
t2 =0.0001*round(10000*t2);
t3 =0.0001*round(10000*t3);
t4 =0.0001*round(10000*t4);
F1 =0.0001*round(10000*F1);
t = 0:.001:t4;
F = zeros(size(t));
F((t>=0&t<=t1)) = F1;
F((t>t1&t<t2)) = 0;
F((t>=t2&t<=t3)) = F1;
F((t>=t3&t<=t4)) = 0;
plot(t,F)
figure
k=fourier(F);
plot(t,F)
figure
g=fft(F);
plot(abs(g),[0,100000])
----------------------------------- run
define L (lenght of wagon -m) : 24.5
define V (speed of train -km/h) : 270
define X1(distance betwean 2 wagon -m) : 0.6
define X2(distance betwean 2 middle wheels -m): 20
define X (distance betwean 2 near wheels -m) : 1.5
define W (total weight of wagon and passenger -ton) : 100
*** V : (speed of train)= 75 m/s
*** L : (lenght of wagon) = 24.5 m
*** X1: (distance betwean 2 wagon) = 0.6 m
*** X2: (distance betwean 2 middle wheels) = 20 m
*** X : (distance betwean 2 near wheels) = 1.5 m
*** W : (total weight of wagon) = 100 ton
*** F1: (force of 1 wheel) = 122.625 kN
*** F1 = 122.625 kN
* t1 = 0.02 s
* t2 = 0.28667 s
* t3 = 0.30667 s
* t4 = 0.33467 s
Undefined function 'fourier' for input arguments of type 'double'.
Error in Untitled (line 47)
k=fourier(F);
0 comentarios
Respuestas (1)
Walter Roberson
el 14 de Oct. de 2013
Editada: Walter Roberson
el 14 de Oct. de 2013
Your F is a numeric vector. You can apply a Fast Fourier Transform (fft) or short time fft or the like to a numeric vector, but you cannot apply a full Fourier transform to a numeric vector. A full Fourier transform is something that can only be applied to symbolic expressions.
3 comentarios
Walter Roberson
el 14 de Oct. de 2013
You would look back to your previous Question where I showed the symbolic form http://www.mathworks.co.uk/matlabcentral/answers/90014-how-we-can-define-piecewise-function-in-matlab#comment_173844
You can fourier() the result of the subs() that I show there. Be sure to provide the two additional parameters that the symbolic fourier routine calls for.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!