当我在matlab中运行此代码时,它将g4值打印到数组列g3中,并且其计算值是假设的,以及它自己的列。我只是想知道如何阻止g4被放入g3的列中,而是在两个数组中打印g3及其值。
干杯
v_meas = 0;
g1 = 1.09;
g2 = 0.9;
g3 = 0.93;
g4 = 0.85;
radius = 3.75;
K = 0.006;
m = g1;
g = g3;
for ii = 1 : 1 : 2
v_meas = m*((radius^2)*pi)*K;
ArrayOfDarceys(1,ii) = v_meas;
ArrayOfGradients(1,ii) = m;
v_meas = 0;
m = g2;
for jj = 3 : 1 : 4
v_meas = g*((radius^2)*pi)*K;
ArrayOfDarceys(1,jj) = v_meas;
ArrayOfGradients(1,jj) = g;
v_meas = 0;
g = g4;
end
end
ArrayOfDarceys
ArrayOfGradients
答案 0 :(得分:2)
我怀疑你不打算嵌套你的for循环。试试这个:
ArrayofGradients = [1.09,0.9,0.93,0.85]
ArrayofDarceys = ArrayofGradients*((radius^2)*pi)*K
如果我了解您要做的事情,您可以大大简化您的代码。事实上,没有任何for循环:
__init__