Parfor "Index exceeds Matrix Dimension"

1 次查看(过去 30 天)
I am trying to do the following. I am repeatedly getting the error message as "Index exceeds Matrix Dimensions". I am not able to figure out why. The variable can be declassified also. Here is my code.
i = 1;
Pv = linspace(10,1000,100); Mrc = 9; Vdiscc = 0.000125;
HEDc(1,1:100) = 318; Cpw = 4.179; dfc = linspace(0,0,100);
parfor j = 1:1:100
for r = 1:1:100
hf = interp1(WPresSat(:,1),WPresSat(:,7),Pv(1,j));
hfg = interp1(WPresSat(:,1),WPresSat(:,8),Pv(1,j));
dfc(j,:) = (HEDc(i,:)*Cpw-hf)/hfg;
if dfc(j,:) < 0
dfc(j,:) = 0;
end
end
end
  2 个评论
Walter Roberson
Walter Roberson 2015-10-14
Which line does the error occur on? What is size(WPressSat) ?
Walter Roberson
Walter Roberson 2015-10-14
Caution:
if dfc(j,:) < 0
is only true if all dfc(j,:) < 0 .
Consider using
dfc(j,:) = max(0, dfc(j,:));

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by