Filter löschen
Filter löschen

says unused value , consider it by replacing it by~, how do I fix it ?

5 Ansichten (letzte 30 Tage)
Abhisekh Maurya
Abhisekh Maurya am 15 Apr. 2020
Beantwortet: Steven Lord am 15 Apr. 2020
in the following loop a message is being displayed for both U and A
"the value assign here to U appears to be unused consider replacing it by ~"
same for 'A'
please help me out . <_>
syms ht U A L
[ht, U, A, L] = solve((ht == kt/di*(3.657 + (0.0677*(Ret*Prt*((di/L).^1.33)).^1/3))/(1+0.1*Prt*(Ret*(di/L)).^0.3)), U == 1/((1/hs)+Rfs+(x(2)/di)*(Rft+(1/ht))), A == Q/(U*F*LMTD), L == A/(pi*x(2)*Nt));
if Ret < 2300
ht = kt/di*(3.657 + (0.0677*(Ret*Prt*((di/L).^1.33).^(1/3)))/(1+0.1*Prt*(Ret*(di/L)).^0.3));
else
if Ret > 2300 && Ret < 10000
ht = kt/di*((1+di/L).^0.67*(ft/8)*(Ret - 1000)*Prt/(1+12.7*((ft/8).^0.5)*((Prt.^(2/3))-1)));
else
if Ret > 10000
ht = 0.027*kt/do*(Ret.^0.8)*(Prt.^(1/3)).*(mewt/mewwt).^0.14;
end
end
end

Antworten (2)

Geoff Hayes
Geoff Hayes am 15 Apr. 2020
Abhisekh - the message is just a warning so could be ignored. All it is telling you to do is to replace the U and A with ~ like
syms ht L
[ht, ~, ~, L] = = solve((ht == kt/di*(3.657 + (0.0677*(Ret*Prt*((di/L).^1.33)).^1/3))/(1+0.1*Prt*(Ret*(di/L)).^0.3)), U == 1/((1/hs)+Rfs+(x(2)/di)*(Rft+(1/ht))), A == Q/(U*F*LMTD), L == A/(pi*x(2)*Nt));
If you do that, then there is no need to declare either of these variables.

Steven Lord
Steven Lord am 15 Apr. 2020
Rather than assuming that solve returns the variables in the order you think it does (since you haven't specified the order, it uses symvar to determine the order) I would call solve with one output (I'll call it sol for the rest of this answer.) That one output will be a struct array, and the values for ht, U, A, and L will be stored as sol.ht, sol.U, sol.A, and sol.L regardless of what order symvar lists them. This will also avoid the "unused value" Code Analyzer message, since you'll likely be doing something with the sol variable later in your code.
After doing that, if you want to use some or all of the variables stored in sol without having to prefix them every time with "sol." I'd define the ones that I planned to use as "independent" variables.
% I plan to use ht and L later on so
ht = sol.ht;
L = sol.L;

Community Treasure Hunt

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

Start Hunting!

Translated by