필터 지우기
필터 지우기

important

조회 수: 1 (최근 30일)
Nasir Qazi
Nasir Qazi 2012년 5월 4일
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
Walter Roberson
Walter Roberson 2012년 5월 4일
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Walter Roberson
Walter Roberson 2012년 5월 4일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 4일
Use "switch", or use a table of initial values that you index into.
  댓글 수: 2
Nasir Qazi
Nasir Qazi 2012년 5월 4일
% 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 2012년 5월 4일
switch c(i)
case 1
Tc(1,i) = 190;
case 2
...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by