Why doesn't it work, mixing arrays with non-array cumulative in a loop
Ältere Kommentare anzeigen
I'm trying to combine an array calc and a cumulative sum in a loop (work once or twice, then can't combine the culm value in the G(k) calculation):
clear all
pwidth=.05;
p=0.4;
pi=3.1416;
for k=3:5 %limit1 %limit1 is 5 for n=10
x1(k)=((k-1)*pwidth)-(.75*pwidth); %vortices?
x2(k)=x1(k)-(pwidth/2); %Cps?
y(k)=mult1*((2*p*(x2(k)))-((x2(k))^2));
yp(k)=mult1*((2*p)-(2*x2(k)));
G(k)=(pwidth*pi)*(alpha-yp(k))-culmG;
culmG=culmG+G(k);
end
Antworten (1)
Sean de Wolski
am 12 Dez. 2013
mult1,culmG,alpha are not defined as variables or functions. Thus you need to define them after the clear all.
pwidth=.05;
p=0.4;
mult1 = 1; %example
alpha = 1; %example
culmG = 1; %example
pi=3.1416;
for k=3:5 %limit1 %limit1 is 5 for n=10
x1(k)=((k-1)*pwidth)-(.75*pwidth); %vortices?
x2(k)=x1(k)-(pwidth/2); %Cps?
y(k)=mult1*((2*p*(x2(k)))-((x2(k))^2));
yp(k)=mult1*((2*p)-(2*x2(k)));
G(k)=(pwidth*pi)*(alpha-yp(k))-culmG;
culmG=culmG+G(k);
end
Kategorien
Mehr zu Sources finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!