Shooting Method: issues with zero

1 回表示 (過去 30 日間)
Laura Bell
Laura Bell 2020 年 1 月 13 日
回答済み: Jyotsna Talluri 2020 年 1 月 17 日
I am struggling with Problem 24.16 (see attatched). This is the code I have been using, but I keep getting the following error:
Error using fzero (line 306)
FZERO cannot continue because user-suppliedfunction_handle ==> hw7_24p16res failed with theerror below.
Undefined function 'hw7_24p16dydxn' for input arguments of type 'double'.
Error in hw7_24p16 (line 55)
[x,y]=ode45(@hw7_24p16dydxn,tspan,[5 fzero(@hw7_24p16res,L)]);
Here is my code:
clear all
close all
E=200*10^9;%in Pa
I=30000*10^(-8);%m^4
w=15*10^3;%N/m
L=3;%m
x=[0 L];
y=[0 0];
fprintf('(b) the shooting method\n')
fprintf('\n')
tspan=x;
[x,y]=ode45(@hw7_24p16dydxn,tspan,[5 fzero(@hw7_24p16res,L)]);
plot(x,y(:,1))
Functions:
function [dy]=hw7_24p16ydxn(x,y)
E=200*10^9;%in Pa
I=30000*10^(-8);%m^4
w=15*10^3;%N/m
L=3;%m
%x=[0 L];
%y=[0 0];
dy=[y(2);
(w*L*x-w*x^2)/(2*E*I)];
end
function [r]=hw7_24p16res(za)
[x,y]=ode45(@hw7_24p16dydxn,[0 L],[0 za]);
r=y(end,1)-0;
HELP!
  1 件のコメント
darova
darova 2020 年 1 月 13 日
It means that function with this name doesn't exist
Undefined function 'hw7_24p16dydxn' for input arguments of type 'double'.
Look
function [dy]=hw7_24p16ydxn(x,y)

サインインしてコメントする。

回答 (1 件)

Jyotsna Talluri
Jyotsna Talluri 2020 年 1 月 17 日
You have defined a function with function name hw7_24p16ydxn and you are calling a function 'hw7_24p16dydxn' which does not exist

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by