Parfor "Index exceeds Matrix Dimension"

조회 수: 1 (최근 30일)
Vishakh Ranade
Vishakh Ranade 2015년 10월 14일
댓글: Walter Roberson 2015년 10월 14일
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