0

So the code goes something like this..

for i=1:5
x(i) = input(['Input for number', i );
end

when i run, instead i get something like "Input a complex number []" where [] is just a block (i cannot get the symbol here), how do i make it so for every input it can say "Input for number 1", "Input for number 2", etc?

0

1 Answer 1

3

When casting from double to char, you convert between ASCII-Codes and the character. To get the character 1 use num2str

for i=1:5
  x(i) = input(['Input for number ', num2str(i)]);
end
Sign up to request clarification or add additional context in comments.

1 Comment

@JitheshSrinivas Rather than a "thank you" comment, which is not really what the comments are for, it would be better to accept the answer that you think best by clicking the check (tick) mark to the left. Please read stackoverflow.com/help/someone-answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.