Effacer les filtres
Effacer les filtres

matlab preallocation problem in for loop

2 vues (au cours des 30 derniers jours)
WANYI ZHANG
WANYI ZHANG le 23 Avr 2019
Commenté : WANYI ZHANG le 23 Avr 2019
Hi
Can anyone tell me how can I fix this preallocation problem in matlab.
Thanks!
fluid_HX = struct;
for j=1:length(t)
fluid_HX{j}=refprop(v(j),T_in(j),r410a);
end
  1 commentaire
KSSV
KSSV le 23 Avr 2019
YOu have initialized fluid_HX as a structure. Read about structures...it needs some field value.
If you want a cell initialize it as a cell.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 23 Avr 2019
fluid_HX = cell(length(t),1);
for j=1:length(t)
fluid_HX{j}=refprop(v(j),T_in(j),r410a);
end
  1 commentaire
WANYI ZHANG
WANYI ZHANG le 23 Avr 2019
Thanks a lot!
That worked

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by