필터 지우기
필터 지우기

Question about input and loop for the range of plots

조회 수: 2 (최근 30일)
yc j
yc j 2015년 12월 14일
댓글: yc j 2015년 12월 14일
Hello, I am trying to make plots with my data.
I got data that can be sorted to set A and set B depending on ranges.
For example,
the ranges of A are: xlim([0 1]); ylim([0 2])
the ragnes of B are: xlim([0 5]); ylim([0 10])
So first I make my m-code choose the data file by using uigetfile command.
Then, I do something like &nbsp tt=input('type A or B:\n'); &nbsp So I can select which type of data i'm dealing with.
Then, I put 'if loop' to select the range..:
if tt=A
...
xlim([0 1]);
ylim([0 2])
...
elseif tt=B
... something like this.
end
This of course wouldn't work...
How should I setup the code?
  댓글 수: 2
per isakson
per isakson 2015년 12월 14일
Why &nbsp "This of course wouldn't work" ?
yc j
yc j 2015년 12월 14일
just saying... nothing important

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

채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 14일
tt = input('type A or B: ', 's');
if strcmp(tt, 'A')
xlim([0 1]); ylim([0 2]);
elseif strcmp(tt, 'B')
xlim([0 5]); ylim([0 10]);
else
error('You needed to answer with A or B')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by