필터 지우기
필터 지우기

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일
편집: 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에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by