Projectile as a height handle, fzero used as a function of function to find hitting ground, syntax> fzero(function_handle, x_guess) guess by user hitting ground

1 次查看(过去 30 天)
clc; clear all; close all;
% height_handle = @(t) height(t)
height_handle = @(t) -(9.8./2)*t^2+125*t+500
fplot(height_handle,[0,60])
x_guess=input('Enter a value when it will hit ground:')
% abs_height_handle=mod(height_handle) % tried abs(height_handle) does not
% work
function_handle=fzero(abs_height_handle,[0,60])
fzero(function_handle, x_guess)
ground=fzero(function_handle, 40)
% get the following errors
Error in Untitled2 (line 6)
abs_height_handle=mod(height_handle) % tried abs(height_handle) does not

采纳的回答

Harsha Priya Daggubati
编辑:Harsha Priya Daggubati 2020-5-15
Hi,
It is advised to clearly explain your issue as text instead of title. Also leverage using code section to post your code. I assume your issue is in line 6. It is because the declared function handle height_handle, expects an input argument whenever a call is made. The following link might help you understand function handles better.
You can correct your call such that you pass an argument.
abs_height_handle= mod(height_handle(x_guess)) %I guess you should pass x_guess!
Also, mod expects two input arguments 'a' and 'm'. You can look into the following documentation link and figure out which method out of mod and abs to use.
Hope this solves your issue!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by