Azzera filtri
Azzera filtri

Using for loop for midpoint method

1 visualizzazione (ultimi 30 giorni)
Khang Nguyen
Khang Nguyen il 21 Mag 2019
Hi guys, this is my code
m = 1000;
f = 75000;
v0 = 0;
h = 0.1;
tspan = [0 10];
c = [50,100,500,1000,2000];
dvdt = cell(1,length(c));
for i = 1:length(c);
dvdt{i} = @(t,v) (f-c{i}*v)/m;
end
t =cell(1,length(c));
v =cell(1,length(c));
for k = 1:length(c)
[t{k},v{k}]=midpoint(dvdt{1,k},tspan,v0,h)
end
%% Question
I want to use midpoint to calculate the t and v, and my dvdt is relied on c(constant values run from 50 to 2000). The code works, but t and v are released just only based on c = 50, which means my for loop does not work. Can someone please help !!!
Thanks in advance

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by