Parfor "Index exceeds Matrix Dimension"

1 visualizzazione (ultimi 30 giorni)
Vishakh Ranade
Vishakh Ranade il 14 Ott 2015
Commentato: Walter Roberson il 14 Ott 2015
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 Commenti
Walter Roberson
Walter Roberson il 14 Ott 2015
Which line does the error occur on? What is size(WPressSat) ?
Walter Roberson
Walter Roberson il 14 Ott 2015
Caution:
if dfc(j,:) < 0
is only true if all dfc(j,:) < 0 .
Consider using
dfc(j,:) = max(0, dfc(j,:));

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by