Matlab does not seem to recognise my inputted commands
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am currently writing a set of codes but i cannot get Matlab to recognise that i have defined values for t. I have been told to use the "interpl" command but that doesn't seem to work either so i'm unsure how to debug this.
Here are my codes:
This is the file named daisyworld1
Lt=linspace(0,5); %generate t for L
L=5*Lt+2; %luminosity function
f=interpl(Lt,L,t); %interpolate the data set (Lt,L) at time t
function dydt =daisyworld1(t,y,Lt,L);
dydt = [0;0];
A=((1-y(1)-y(2))*0.5)+(y(1)*0.25)+(y(2)*0.75); %albedo
S=917; %constant solar energy
Z=5.67*10^(-8); %Stefan-Boltzmann constant;
Te=((((S*L)/Z)*(1-A)).^(1/4))-273; %plantary temperature
B=1-0.003265*((22.5-Te).^2); %beta value, local temperature function
g=0.2; %x-value
dydt(1)=y(1)*(( (1-y(1)-y(2)) *B)-g);
dydt(2)=y(2)*(( (1-y(1)-y(2)) *B)-g);
And this is the code for solving it using ode45
t0=0; % Start time
tf=0.5; % End time
Lt=linspace(0,5,25); %generate t for L
L=5*Lt+2; %luminosity function
L=interpl(Lt,L,t); %interpolate the data set (Lt,L) at time t
options=odeset('RelTol', 1e-4);% Sets the error tolerance of the ODE solver
aw=0.4; % Initial white daisy area
ab=0.2; % Initial black daisy area
[t, y]=ode45(@(t,y)daisyworld1(t,y,Lt,L),[aw ab],options); % Solves the equations
plot(t,y) % Plots the daisy area coverage against time
% Blue line is white daisies
% Green line is black daisies
The error message i keep getting is
Undefined function or variable 't'.
Error in daisyworldode45 (line 11)
L=interpl(Lt,L,t); %interpolate the data set (Lt,L) at time t
I am trying to plot the coverage of daisies against Luminosity which i am using an increasing function of time for.
Any help would be much appreciated, thank you.
0 comentarios
Respuesta aceptada
Thorsten
el 21 de Feb. de 2013
You have to define t before you can use it
t = ... % whatever you need
L = interpl(Lt,L,t);
0 comentarios
Más respuestas (1)
Walter Roberson
el 20 de Feb. de 2013
You seem to have three lines of code before you define your function "daisyworld1". That is a problem.
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!