How do I make a function with 2 parameters?

조회 수: 6 (최근 30일)
Mattias Hertzberg
Mattias Hertzberg 2020년 11월 18일
댓글: Rik 2020년 11월 18일
I tried this which apparently worked previously but when i try it it doesnt work
>>function y=kastbana(x, theta)
>>t=theta*pi/180; % theta i grader, t i radianer
>>v0=10; y0=1.85; g=9.81;
>>a=g/(2*v0^2*cos(t)^2); b=v0^2*sin(2*t)/(2*g); c=v0^2*sin(t)^2/(2*g);
>>y=y0-a*(x-b).^2+c;
">> kastbana(x,theta)
Unrecognized function or variable 'theta'."
  댓글 수: 2
Rik
Rik 2020년 11월 18일
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). That might be more effective than posting a question and waiting for a response.
Mattias Hertzberg
Mattias Hertzberg 2020년 11월 18일
Thanks! I didn't know about that, but I'm just wondering if theres a small mistake I've done here.

댓글을 달려면 로그인하십시오.

답변 (1개)

madhan ravi
madhan ravi 2020년 11월 18일
Man muss einfach versuchen.
doc function
  댓글 수: 5
Mattias Hertzberg
Mattias Hertzberg 2020년 11월 18일
Update: I made a new file and typed in the function again and now it worked somehow. I don't know why but anyway. Thanks for the help. What does "doc" do?
Rik
Rik 2020년 11월 18일
The doc command searches the documentation. So running doc function in your command window will open the documentation page for the function keyword. That will contain an explanation about how to use it, and some examples and links.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by