필터 지우기
필터 지우기

Creating a variable number of prompts.

조회 수: 4 (최근 30일)
Steven Latham
Steven Latham 2019년 12월 10일
댓글: Steven Latham 2019년 12월 11일
So I'm just going to preface this saying that I'm very much still learning Matlab and not very proficent with the software yet.
My question is i'm trying to create a prompt that appears n times where n = an eariler input value. I have no idea where to begin with the code for this.
Here is what I have so far for this section. the end goal is to have the prompt appear like this:
Percent for test 1: xx.x
Percent for test 2: xx.x
......
Percent for last test: xx.x
prompt = {'Enter Your Name.', 'Number of Tests Taken. '};
dlgtitle = 'Name & Tests Taken';
dims = [1 50];
definput = {'Name','# of tests'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
N = answer(1:1); % name entered in first box
T = answer(1:2); % Number of tests taken
TT = input('Percent for first test '); % Need to make varible # of prompts = T

채택된 답변

Ridwan Alam
Ridwan Alam 2019년 12월 11일
편집: Ridwan Alam 2019년 12월 11일
prompt = {'Enter Your Name.', 'Number of Tests Taken. '};
dlgtitle = 'Name & Tests Taken';
dims = [1 50];
definput = {'Name','# of tests'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
% you're good upto this point
N = answer{1}; % name entered in first box
T = str2num(answer{2}); % Number of tests taken
TT = zeros(T,1);
for i = 1:T
TT(i) = input(['Percent for test ',num2str(i),': ']);
end
%% TT stores all the scores
  댓글 수: 1
Steven Latham
Steven Latham 2019년 12월 11일
Thanks for the help this did the trick. Most everything is running smooth now.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by