important

1 Ansicht (letzte 30 Tage)
Nasir Qazi
Nasir Qazi am 4 Mai 2012
disp('1 for comp1');disp('2 for comp2');disp('3 for comp3');disp('4 for comp4');disp('5 for comp5');disp('6 for comp6');disp('7 for comp7');
% in the above components I want to select components
nc = input('Input the components')
% for example nc = 3 , now after giving this each component has a value of a variable Tc, Pc, w associated with it , how can I assign particular variable values after selecting my components
  2 Kommentare
Walter Roberson
Walter Roberson am 4 Mai 2012
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Walter Roberson
Walter Roberson am 4 Mai 2012
Please use titles that give an indication of the content of the question being asked. I looked back over the Questions that you have asked, and you have often used titles that do not give any indication of the subject area. People tend to skip over Questions that have meaningless titles.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 4 Mai 2012
Use "switch", or use a table of initial values that you index into.
  2 Kommentare
Nasir Qazi
Nasir Qazi am 4 Mai 2012
% I did but I want it to assign the value of Tc according to the ordering of selecting my components like I did below but it doesn't select the values according to the error
disp('1 for CH4');disp('2 for CO2');disp('3 for N2');
nc =input('components');
if nc > 5
disp('Too Many component')
break
end
for i=1:nc
c(i)=input('c');
switch c(i)
case {c(1)==1}
Tc(1,1) = 190;
case {c(2)==2}
Tc(1,2) = 120;
case {c(3)==3}
Tc(1,3) = 890;
case {c(4)==4}
Tc(1,4) = 1210;
case {c(5)==5}
Tc(1,5) = 1990;
otherwise
disp('enter the comp')
end
end
Walter Roberson
Walter Roberson am 4 Mai 2012
switch c(i)
case 1
Tc(1,i) = 190;
case 2
...

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by