where to put "." notion in x(t) equations in MATLAB

3 views (last 30 days)
Hi.
I am about to plot x(t) and I wrote its function but since it requires t , it needs elements wise operators. Where do I need to put "." notion (dot notion) ? before or after t ? and does it require to re-write it all ? I don't know ehere to put "." notioan in MATLAB equations. Is there any rule fo rthat?
y1=(e^(zeta*(-1)*t))*((x0*cos(w0*sqrt(1-zeta^2)*t))+(v0+zeta*w0*x0)*sin(sqrt(1-zeta^2)*t)/(w0*sqrt(1-zeta^2)));
y2=(e^(zeta*(-1)*t))*(x0+t*(zeta*w0*x0));
y3=y=(e^(zeta*(-1)*t))* ...
(((v0+(zeta+sqrt(zeta^2-1))))*e^w0*sqrt(zeta^2-1)/t*2*w0*sqrt(zeta^2-1) + ...
((-v0+(-zeta+sqrt(zeta^2-1))))*e^(-1)*w0*sqrt(zeta^2-1)/t*2*w0*sqrt(zeta^2-1));

Accepted Answer

Fatemeh Salar
Fatemeh Salar on 9 Jul 2022
Thanks to @David Hill for puting . notion and @John D'Errico for correting exp(), Here is the answer and its working :)
y=(exp(zeta.*(-1).*t)).*((x0.*cos(w0.*sqrt(1-zeta.^2).*t))+(v0+zeta.*w0.*x0).*sin(sqrt(1-zeta.^2).*t)./(w0.*sqrt(1-zeta.^2)));
y=(exp(zeta.*(-1).*t)).*(x0+t.*(zeta.*w0.*x0));
y=(exp(zeta.*(-1).*t)).* ...
(((v0+(zeta+sqrt(zeta.^2-1)))).*exp(w0.*sqrt(zeta.^2-1).*t)./2.*w0.*sqrt(zeta.^2-1) + ...
((-v0+(-zeta+sqrt(zeta^2-1))))*exp(-1*w0.*sqrt(zeta.^2-1).*t)./2.*w0.*sqrt(zeta.^2-1));

More Answers (1)

David Hill
David Hill on 9 Jul 2022
y1=(e^(zeta*(-1)*t)).*((x0*cos(w0*sqrt(1-zeta^2)*t))+(v0+zeta*w0*x0)*...
sin(sqrt(1-zeta^2)*t)/(w0*sqrt(1-zeta^2)));
y2=(e^(zeta*(-1)*t)).*(x0+t*(zeta*w0*x0));
y3=y=(e^(zeta*(-1)*t)).*(((v0+(zeta+sqrt(zeta^2-1))))*e^w0*...
sqrt(zeta^2-1)./t*2*w0*sqrt(zeta^2-1)+...
((-v0+(-zeta+sqrt(zeta^2-1))))*e^(-1)*w0*sqrt(zeta^2-1)./t*2*w0*sqrt(zeta^2-1));
%./t is only dividing by t not (t*2*w0*sqrt(zeta^2-1)), you will need () to
%divide by the whole thing. You could put '.' infront of all operators and it
%would not matter
  1 Comment
John D'Errico
John D'Errico on 9 Jul 2022
There are several misleading statements in this answer, and part of it is just flat out wrong.
  1. You CANNOT put a dot in front of all operators. This very much does matter, since there is no .+ or .- operator in MATLAB.
  2. Assuming that e and zeta are scalars, and t is a vector, then you MUST have a . in front of the ^ operator. Any such expression will fail otherwise.
  3. Assuming that e is intended as the exponential constant, this 2.71828..., then e^(stuff) is best represented as exp(stuff). This will probably be more accurate, and will also result in faster, more efficient code.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!