필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Fatemeh Salar
Fatemeh Salar 2022년 7월 9일
답변: Fatemeh Salar 2022년 7월 9일
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