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 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Harsha Priya Daggubati
Harsha Priya Daggubati le 15 Mai 2020
Modifié(e) : Harsha Priya Daggubati le 15 Mai 2020
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!

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by