fzero help
2 次查看(过去 30 天)
显示 更早的评论
buxZED
2011-2-24
y=@(T) I*T*sind(A)-(0.5*G*(T^2));
root = fzero(y, 0)
abouve eqation is for a projectile that projected at an angle (gose in a kind of ar half oval shape)
want to find the time it hist ground but fzero only gives me the biginning which is 0
23 个评论
Walter Roberson
2011-2-24
Maybe it just doesn't like buxZED... won't let me submit an answer to this one.
Paulo Silva
2011-2-24
Hey Walter, answers stop working for me too :(
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
buxZED
2011-2-24
??? Error using ==> fzero at 260
Function values at interval endpoints must be finite and real.
Error in ==> p34 at 26
root = fzero(y,[eps, realmax])
>>
buxZED
2011-2-24
@matt Fig
that was my inicial thought
but we are not alowed to use neumerical methods or guess work
Walter Roberson
2011-2-24
Ummm, make it fzero(y,[eps,sqrt(realmax)/G]
Using fzero(y,eps,realmax) would cause realmax to be interpreted as an Option, and then it would use eps as the starting guess, not constrained from going backwards.
Walter Roberson
2011-2-24
No, there is no way to force fzero to go to the next positive root. You can only exclude the area you already searched from the area fzero is to search next.
buxZED
2011-2-24
it works
but i want to understand what while ~rt means (what dose ~ say)
dose this stop counting as it finds the first root after zero?
Walter Roberson
2011-2-24
~ is logical negation. It is true if and only if the thing being tested is exactly 0.
buxZED
2011-2-24
y=@(T) I*T*sind(A)-(0.5*G*(T^2));
%root = fzero(y, eps, realmax)
rt = 0;
d = .1;
cnt = 1;
while ~rt
rt = fzero(y,rt+d*cnt);
cnt = cnt + 1;
end
fprintf('the root is %g\n' , rt)
gives me the root is 7.11215e-026
but its not posible as the projectile takes around 1.5sec to reach maximum hight, the root should be around 3
can you point me in the right derection?
buxZED
2011-2-24
is there a way to systematicaly increase the T value till Y become zero and get that value?
Matt Fig
2011-2-24
Change from:
while ~rt
to:
while rt<.1
or similar. It might help if you actually gave us some values for I, A and G.
buxZED
2011-2-24
it worked Matt
thank you so much
and also ~ would allow me to use matlab in many new ways
thank you again :D
Matt Fig
2011-2-25
Come on now, Matt! Where is the fun of solving the equation with your brain instead of making MATLAB do it?
采纳的回答
Honglei Chen
2012-9-17
The anwser is in the comments above
From Matt Fig
rt = 0;
d = .1;
cnt = 1;
while rt<.1
rt = fzero(y,rt+d*cnt);
cnt = cnt + 1;
end
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)