Filter löschen
Filter löschen

Unable to perform assignment

2 Ansichten (letzte 30 Tage)
Michael Käufl
Michael Käufl am 13 Jan. 2020
Beantwortet: Walter Roberson am 14 Jan. 2020
Hello Guys,
I've got this error message every time: Index exceeds the number of array elements (1).
Error in Neu_HTU>@(T_H2O,h_Luft)cp_H2O*Massenstromverhaeltnis*(1+(X_sat(i)-X(i))*cp_H2O*T_H2O(i)./Ch(i)) (line 112)
f1 = @(T_H2O,h_Luft) cp_H2O * Massenstromverhaeltnis *(1+(X_sat(i)-X(i))*cp_H2O*T_H2O(i)./Ch(i));
Error in Neu_HTU (line 114)
l1 = f1((T_H2O(i) ),(h_Luft(i) ));
Can anybody help me?
Cheers Michael
for i=1:ceil(T_H2O_aus/h) % calculation loop
T_H2O(i+1) = T_H2O(i)+h;
X_sat(i) = 0.622 * p_sat_Antoine(T_H2O(i))/(p - p_sat_Antoine(T_H2O(i)));
h_Luft_sat(i) = (cp_Luft + cp_Dampf * X_sat(i)) * (T_Luft_unten -273.15) + X_sat(i) * h_verdampfung;
A(i) = 0.865^(2/3)*(((0.622+X_sat(i))./(0.622+X(i))-1)/(log((0.622+X_sat(i))./...
(0.622+X(i)))));
Massenstromverhaeltnis = M_H2O_ein/M_Luft*(1 - M_Luft/M_H2O_ein*(X_oben-X(i)));
Ch(i) = h_Luft_sat(i) - h_Luft(i) + (A(i)-1)*(h_Luft_sat(i) - h_Luft(i) - (X_sat(i) - X(i)).*...
(h_verdampfung + cp_Dampf*T_H2O(i))) - (X_sat(i) - X(i)).*cp_H2O.*T_H2O(i);
%Funktion 1
f1 = @(T_H2O,h_Luft) cp_H2O * Massenstromverhaeltnis *(1+(X_sat(i)-X(i))*cp_H2O*T_H2O(i)./Ch(i));
l1 = f1((T_H2O(i) ),(h_Luft(i) ));
l2 = f1((T_H2O(i) + 0.5*h),(h_Luft(i) + 0.5*h*l1));
l3 = f1((T_H2O(i) + 0.5*h),(h_Luft(i) + 0.5*h*l2));
l4 = f1((T_H2O(i) + h),(h_Luft(i) + h*l3));
h_Luft(i+1) = h_Luft(i) + h/6*(l1+2*l2+2*l3+l4);
%Funktion 2
f2 = @(T_H2O,X) cp_H2O * Massenstromverhaeltnis * ((X_sat - X)./Ch);
k1 = f2((T_H2O(i) ),(X(i) ));
k2 = f2((T_H2O(i) + 0.5*h),(X(i) + 0.5*h*k1));
k3 = f2((T_H2O(i) + 0.5*h),(X(i) + 0.5*h*k2));
k4 = f2((T_H2O(i) + h),(X(i) + h*k3));
X(i+1) = X(i) + h/6*(k1+2*k2+2*k3+k4);
%X_result = X(i+1);
end

Antworten (1)

Walter Roberson
Walter Roberson am 14 Jan. 2020
T_H2O(i+1) = T_H2O(i)+h;
Okay, you are growing the vector T_H2O as you go, and if T_H2O(i) did not exist then you would not have gotten past that line. So we know that afterwards T_H2O(i+1) will exist.
f1 = @(T_H2O,h_Luft) cp_H2O * Massenstromverhaeltnis *(1+(X_sat(i)-X(i))*cp_H2O*T_H2O(i)./Ch(i));
This function accepts a parameter that for the purposes of the expression will be called T_H2O . This parameter will not necessarily have anything to do with the vector T_H2O that we established above will have at least at least i+1 elements. You need to mentally re-write the line as something like
f1 = @(FirstParameter,SecondParameter) cp_H2O * Massenstromverhaeltnis *(1+(X_sat(i)-X(i))*cp_H2O*FirstParameter(i)./Ch(i));
Whatever first parameter you pass in is going to be indexed at i.
l1 = f1((T_H2O(i) ),(h_Luft(i) ));
You extract a single element from T_H2O and pass that as the first parameter to f1, passing in a scalar there. But f1 wants to access that scalar at index i.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by