Parfor "Index exceeds Matrix Dimension"
3 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 14 Oct 2015
Caution:
if dfc(j,:) < 0
is only true if all dfc(j,:) < 0 .
Consider using
dfc(j,:) = max(0, dfc(j,:));
Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!