I Would like to create a variable array based upon user inputs.
显示 更早的评论
I have a variable that the user inputs called Type allocated as such:
n=input('How many measurements are you determining uncertainty upon? ');
Type=size(n)';
Uo=1;
while Uo<=n;
if Uo==1;
Type(Uo)=input('What type of measurement is your first measurement? (Input 1,2,or 3 for Pressure,Temperature, and Flow Rate Respectively) ');
Uo=Uo+1;
elseif Uo>1;
Type(Uo)=input('What type of measurement is your next measurement? (Input 1,2,or 3 for Pressure,Temperature, and Flow Rate Respectively) ');
Uo=Uo+1;
end
end
I would like to use these values to create another variable matrix later in my code. I tried the following:
Factor=cell(n:1)
for iter = 1:n
if Type == 1
Factor{iter}=1
elseif Type == 2
Factor{iter}=1
elseif Type ==3
Factor{iter}= 4
elseif Type < 1
break
elseif Type > 3
break
end
end
Could someone shine some light into what I am doing wrong here? or is there a far better method I should be using to do this?
Thanks ahead of time for any help you can lend!
3 个评论
Bob Thompson
2019-1-28
Could someone shine some light into what I am doing wrong here?
What do you mean by wrong? Are you getting an error message? Is there some result that isn't coming out as you expect/desire?
Adam Danz
2019-1-28
Also, could you provide some examples of inputs and expected outputs?
CodeJunkie
2019-1-29
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!