Write a program which asks the user to enter their name and N and integer, and displays that name N times. See the help of input to read strings.
Run 1:
Enter name: Matlab
Enter N: 3
Matlab
Matlab
Matlab

1 Kommentar

Rik
Rik am 29 Mär. 2021
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Riley
Riley am 29 Mär. 2021

1 Stimme

clear
clc
str = input('Enter name:','s') ;
N = input('Enter N:') ;
for i=1:N
disp(str);
end
Try this. But as a starter, you'd better utilize the HELP and get started by your self. You'll find it not that hard.

5 Kommentare

Riley
Riley am 29 Mär. 2021
like @KSSV said "Read about the function input."
Mert Can Sökmen
Mert Can Sökmen am 29 Mär. 2021
ı cant do two queston too can u help them ?
Walter Roberson
Walter Roberson am 29 Mär. 2021
We discourage providing complete answers to homework questions.
Mert Can Sökmen
Mert Can Sökmen am 29 Mär. 2021
These are not my homework. Teacher shared some questıons about mıdterm and ı cant solve this 3 questıon.And he did not share answers. I am thinking this questıons will be in midterm this reason ı have to fınd answers.
Rik
Rik am 29 Mär. 2021
Then it might be attempted academic fraud, instead of being lazy and posting a homework question.
Don't you think you will learn more if you actually try to learn from this question? You can find guidelines for posting homework on this forum here.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

KSSV
KSSV am 29 Mär. 2021

1 Stimme

REad about the function input.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 29 Mär. 2021

Kommentiert:

Rik
am 29 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by