필터 지우기
필터 지우기

While loop construction

조회 수: 1 (최근 30일)
Jared
Jared 2011년 10월 16일
I'm trying to make my code less cluttered by removing unnecessary sections by adding a while loop.
Basically what I have is something to import 1-6 data files (user enters # choice in dialog-call it response) and after some operations, presents them in a few different graphical forms.
Currently I have it (very simplified):
if response=1,
load(file1)
plot(file1)
if response==2,
load(file1)
plot(file1)
load(file2)
plot(file2)
...all the way out to if response==6.
pseudo code of what I want to do:
j=1
while response~=0
load(file'j')
plot(file'j')
j=j+1
response=response-1
I assume I'll have to convert j to a string then combine that with the file string?

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 16일
But remember that by default plot() will clear all previous plots in the axis, so you will either want to subplot() or figure() or "hold on"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by