I have spent the last hour researching and am still having problems trying to create a simple function. It says things like "Undefined function or variable 't' or "not enough input arguments'. All I want to do is create a function: Height(t) that can find the values when the height is 0 based on it's equation, so this is what I did:
function h = Height(t)
h = 2.13*t.^2-0.0013*t.^4+0.000034*t.^4.751;
end
Why does this show an error? And what command can I use to find when h = 0?
Thanks

댓글 수: 1

Adam
Adam 2016년 11월 3일
편집: Adam 2016년 11월 3일
Make sure you run it from command line or another function/script passing in an argument, don't just click the green 'Run' button which obviously cannot possibly supply the 't' input the function expects.
Also, look at
doc fzero

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

 채택된 답변

Torsten
Torsten 2016년 11월 3일

0 개 추천

h=0 when t=0 ; your function does not have other zeros.
Best wishes
Torsten.

댓글 수: 5

Trevor Bedsaul
Trevor Bedsaul 2016년 11월 3일
Thank you, but my main question is how to create a working function. When I simply create that function, it shows up with errors.
Torsten
Torsten 2016년 11월 3일
h=@(t)2.13*t.^2-0.0013*t.^4+0.000034*t.^4.751;
h(1)
Best wishes
Torsten.
Trevor Bedsaul
Trevor Bedsaul 2016년 11월 3일
Apologies, but it turns out that after putting it into a calculator, there is another 0 at around t = 63, so how do I find the exact value of when h(t) = 0 using matlab?
Steven Lord
Steven Lord 2016년 11월 3일
Use fzero as Adam suggested.
Torsten
Torsten 2016년 11월 4일
h=@(t)2.13*t.^2-0.0013*t.^4+0.000034*t.^4.751;
sol=fzero(h,[60 70]);
Best wishes
Torsten.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2016년 11월 3일

댓글:

2016년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by