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

2 次查看(过去 30 天)
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));

采纳的回答

Fatemeh Salar
Fatemeh Salar 2022-7-9
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));

更多回答(1 个)

David Hill
David Hill 2022-7-9
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 个评论
John D'Errico
John D'Errico 2022-7-9
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by