How to change a single word in user interface with the input command?

2 Ansichten (letzte 30 Tage)
Dear matlab community,
I have following code, which does not run yet.
the variable fibres_without_BF contains of a 3x1 cell with some strings. I would like to change the word '%s' systematically in the for loop, but i don't know how the syntax should be. Can someone help me?
Thank you in advance,
Paul
fibres_without_BF = {'40p_546'}
fibres_without_BF{2,1} = {'41p_546'}
for i = 1:length(fibres_without_BF)
ok = input('does AN fibre %s look ok? (y/n) ', fibres_without_BF{i},'s');
end

Akzeptierte Antwort

Vilém Frynta
Vilém Frynta am 7 Feb. 2023
Bearbeitet: Vilém Frynta am 7 Feb. 2023
not sure if I understand your idea, but you could try doing this:
prompt = ['does AN fibre',fibres_without_BF{i},'look ok?']; % create flexible prompt
ok = input(prompt, 's'); % this is the correct syntax
simply, if you want your prompt (question) to change by for loop, you should create the prompt and then just call it inside input function.
edit: another version
prompt = sprintf('does AN fibre %s look ok?',fibres_without_BF{i});
hope it helps ÷)

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by