필터 지우기
필터 지우기

Choosing between different input parameters in the same script

조회 수: 1 (최근 30일)
Giuseppe Napoli
Giuseppe Napoli 2017년 5월 12일
댓글: Giuseppe Napoli 2017년 5월 12일
Hi , I need help with my matlab script. This script is mainly divided into two parts. In the first one I declare the input parameters for my model and in the second one the script does all the "simulation" , is a grain growth and recrystallization model for stainless steel (and I do not need to modify this part, is fixed). I need to change my input parameters (3 simple variables, that is different for each steel) in a clever way. Now I am doing this task commenting all the variable that I do not need. How can I do this ? Moreover this this script also run in a GUI and the I would like to use a pop up menu for selecting this different input. Thanks in advance
e= 0.20;
Ntot = 1e11;
Drho0= 1e8;
%--------------%
e= 0.40;
Ntot = 2e11;
Drho0= 1e9;

채택된 답변

Stephen23
Stephen23 2017년 5월 12일
편집: Stephen23 2017년 5월 12일
Use switch and some appropriate names for those steel types:
switch steel_type
case 'type1'
e = 0.20;
Ntot = 1e11;
Drho0 = 1e8;
case 'type2'
e = 0.40;
Ntot = 2e11;
Drho0 = 1e9;
end
  댓글 수: 1
Giuseppe Napoli
Giuseppe Napoli 2017년 5월 12일
Amazing. I dont know this function and it is perfect for my script. Thanks again

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

추가 답변 (1개)

KSSV
KSSV 2017년 5월 12일
How about this?
iwant = 1 ;
if iwant ==1
e= 0.20;
Ntot = 1e11;
Drho0= 1e8;
elseif iwant ==2
%--------------%
e= 0.40;
Ntot = 2e11;
Drho0= 1e9;
%--------------%
elseif iwant ==3
e= 0.30;
Ntot = 2e12;
Drho0= 1e10;
end

카테고리

Help CenterFile Exchange에서 Biomedical Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by