Undefined function 'F' for input arguments of type 'char'.

8 ビュー (過去 30 日間)
M
M 2014 年 8 月 30 日
コメント済み: M 2014 年 9 月 2 日
I am trying to create a function F(t) that is equal to a convolution integral, and then compute theta_n(n+1) by taking the value F(tn). However, I'm getting the error "Undefined function 'F' for input arguments of type 'char'". What's the problem?
function [ theta ] = Untitled( theta_o,omega_o )
nt=5001; %since (50-0)/.01 = 5000
dt = .01; % =H
H=.01;
theta_n = ones(nt,1);
theta_n(1)=0; %theta_o
omega_n = ones(nt,1);
omega_n(1)=-0.4; %omega_o
epsilon=10^(-6);
eta = epsilon*10;
t_o=0;
for n=1:4999
tn=t_o+n*dt;
F := int((422.11/eta)*exp((5*(4*((eta*t-s-tn)^2)/eta^2)-1)^(-1))*omega, s,tn-(n/2),tn+(n/2))
theta_n(n+1) = theta_n(n) + h*F(tn);
end
end

回答 (4 件)

per isakson
per isakson 2014 年 8 月 30 日
編集済み: per isakson 2014 年 8 月 30 日
Replace the string
Untitled
by
F
and replace
F := int((42 ....
by
F = int((42 ....
and see

M
M 2014 年 9 月 1 日
That didn't solve the problem. I now get the error "Undefined function or variable 't'." I'll post the updated code here:
function [ bigTheta_n ] = F( bigTheta_o, bigOmega_o )
nt=5001; %since (50-0)/.01 = 5000
dt = .01; % =H
H=.01;
l=.05;
bigTheta_n = ones(nt,1);
bigTheta_n(1)=bigTheta_o; %theta_o
bigOmega_n = ones(nt,1);
bigOmega_n(1)=bigOmega_o; %omega_o
littleOmega_n = ones(nt,1);
epsilon=10^(-6);
eta = epsilon*10;
t_o=0;
for n=1:4999
tn=t_o+n*dt;
littleOmega_n(n) = bigOmega_n(n) - sin(bigTheta_n(n))*cos(2*pi*tn/epsilon)/(2*pi*l)
syms s
F=int((422.11/eta)*exp((5*(4*((eta*t-s-tn)^2)/eta^2)-1)^(-1))*littleOmega_n,s,tn-(n/2),tn+(n/2))
bigTheta_n(n+1) = bigTheta_n(n) + H*F; %Algorithm 1, pg. 248
end
end
I get the error "Undefined function or variable 't'."
  2 件のコメント
per isakson
per isakson 2014 年 9 月 1 日
"That didn't solve the problem." &nbsp There are several problems.
M
M 2014 年 9 月 2 日
I already tried the changes below, and the function is still not working

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


M
M 2014 年 9 月 1 日
I re-wrote the function as follows:
function [ bigTheta_n ] = Untitled( bigTheta_o, bigOmega_o )
nt=5001; %since (50-0)/.01 = 5000
dt = .01; % =H
H=.01;
l=.05;
bigTheta_n = ones(nt,1);
bigTheta_n(1)=bigTheta_o; %theta_o
bigOmega_n = ones(nt,1);
bigOmega_n(1)=bigOmega_o; %omega_o
littleOmega_n = ones(nt,1);
epsilon=10^(-6);
eta = epsilon*10;
t_o=0;
function Keta = K(t)
Keta = (422.11/eta)*exp((5*(4*((t-tn)^2)/eta^2)-1)^(-1))
end
function F = F(t)
sys s
F = int(Keta(eta*t-s)*littleOmega_n,s,tn-(n/2),tn+(n/2))
end
for n=1:4999
tn=t_o+n*dt;
littleOmega_n(n) = bigOmega_n(n) - sin(bigTheta_n(n))*cos(2*pi*tn/epsilon)/(2*pi*l);
F = @(t) int(Keta(eta*t-s)*littleOmega_n,s,tn-(n/2),tn+(n/2));
bigTheta_n(n+1) = bigTheta_n(n) + H*F(tn)
end
end
However, after running this, I get the error "Undefined function or variable 's'."
Even if I get rid of the line "F = @(t)..." and replace it with the following (and place it below where Keta = K(t) is defined):
function F = F(t, ti, tf)
F = int(Keta(eta*t-s)*littleOmega_n,s,ti,tf)
end
and then replace the final line of
bigTheta_n(n+1) = bigTheta_n(n) + H*F(tn)
with
bigTheta_n(n+1) = bigTheta_n(n) + H*F(tn, tn-(n/2), tn+(n/2))
I still get the same error "Undefined function or variable 's'."
  2 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 9 月 1 日
編集済み: Geoff Hayes 2014 年 9 月 1 日
M - please stop using the Answer this question box to further the dialog/conversation, since what you are posting does not solve the original question and will just prove confusing for other readers.
You have changed your code considerably in that you have introduced two local functions F and Keta. Why? What is the purpose of each that you feel you need them now?
And you have assigned the output of a statement to F which is the name of your local function.
Look as well at the body of F - what is
sys s
?
The error message, Undefined function or variable 's', should be clear. You are trying to use s before it has been defined. Where in your code are you doing that?
M
M 2014 年 9 月 1 日
Sorry, I didn't see the 'comment on this answer' until now.
As for "sys s", I thought that would matter for the int function. Even if I remove "sys s", I get the same error. 's' is just a dummy variable, so why do I need to define it?

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


per isakson
per isakson 2014 年 9 月 1 日
"'s' is just a dummy variable, so why do I need to define it?" &nbsp
  1 件のコメント
M
M 2014 年 9 月 2 日
I tried
F = @(t) int(@(s) Keta(eta*t-s)*littleOmega_n,s,tn-(n/2),tn+(n/2));
and I still get the messages: "Undefined function or variable 's'.", "Error in Untitled/@(t)int(@(s)Keta(eta*t-s)*littleOmega_n,s,tn-(n/2),tn+(n/2))", "Error in Untitled (line 34) bigTheta_n(n+1) = bigTheta_n(n) + H*F(tn);"

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

カテゴリ

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