Filter löschen
Filter löschen

Creating a variable number of prompts.

4 Ansichten (letzte 30 Tage)
Steven Latham
Steven Latham am 10 Dez. 2019
Kommentiert: Steven Latham am 11 Dez. 2019
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

Akzeptierte Antwort

Ridwan Alam
Ridwan Alam am 11 Dez. 2019
Bearbeitet: Ridwan Alam am 11 Dez. 2019
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 Kommentar
Steven Latham
Steven Latham am 11 Dez. 2019
Thanks for the help this did the trick. Most everything is running smooth now.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by