why 'for' doesnt affect inner function?
1 view (last 30 days)
Show older comments
hello Guys! im trying to have variable 'i' included in outside function called @witodefinicje. I wanna run ode for different 'i' inside @. The problem is that inside @ it stays the same. I have no clue whats wrong, please help
for i=0:50:200
j=j+1;
t = 0:0.01:20;
X0 = zeros(12,1);
X0(10,1) = -pi/2;
X0(11,1) = pi/2;
[t X] = ode45(@witodefinicje, t, X0);
A(j,1)=max(X(600:1800,8));
A(j,2)=i;
end
2 Comments
Jan
on 23 Jun 2018
Today I've formatted the code for you. Please do this by your own in following questions. Thanks. See the "{} Code" button.
What is "an outside function"? What does "inside @" mean? What stay the same?
Accepted Answer
Jan
on 23 Jun 2018
Edited: Jan
on 23 Jun 2018
A bold guess:
X0 = zeros(12,1);
X0(10,1) = -pi/2;
X0(11,1) = pi/2;
t = 0:0.01:20;
for i = 0:50:200
[t, X] = ode45(@(t,x) witodefinicje(t, x, i), t, X0);
j = j + 1;
A(j,1) = max(X(600:1800, 8));
A(j,2) = i;
end
And in the function to be integrated:
function witodefinicje(t, x, i)
...
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!