Parse error Simple Function Problem
이전 댓글 표시
Hi I am brand new to matlab and am writing a simple program for an assignment. We are given a piecewise function with three parts of the height of a rocket. and are supposed to write a function to calculate the height. I did this but am getting a parse error for the t's inside the if and if elses. Any guidance is much appreciated!
Function[y]=height(t)
if(t<0)
y=0;
elseif(t<15)
y=38.1454t+0.13743t^3;
elseif((t<33)&&(t>=15)
y=1036+103.909(t-15)+6.18425(t-15)^2-0.428(t-15)^3;
elseif(t>33)
y=2900-62.468(t-33)-16.9274(t-33)^2+0.41796(t-33)^3
end
채택된 답변
추가 답변 (1개)
iorngbough iorpinen
2019년 10월 6일
0 개 추천
Hi please someone should help out,iam new in MATLAB iam writing a program on two first order differential equation using shooting method and iam getting 'parse'error at the first bracket after the "equal to sign"
Function [dp]=(r,p) E=50;q1=4;q2=-2;B=1672;rho=0.32×10^-9;l=1; do=[p(2);(-2*E-2*q1*q2*r^-1-2*B*exp(-r/rho)+l*(l+1)*r^-2*p(1)];
댓글 수: 3
Steven Lord
2019년 10월 6일
What's the name of this function? Where are you supposed to specify the name of the function when you write it, and where did you specify the name of this function?
Star Strider
2019년 10월 6일
@iorngbough iorpinen —
Please post your Answer as a new Question. It does not relate to this thread.
iorngbough iorpinen
2019년 10월 7일
Please iam sorry it was a mistake
카테고리
도움말 센터 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!