How to change output from column to row?
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
a = input('Enter first number:');
b = input('Enter second number:');
for A=a:b
reshape(A,1,[]);
fprintf('%d \n', A)
end
this is my code but I cant change the answer to horizontal orientation
The output goes like this
Enter first number:1
Enter second number:3
1
2
3
0 Commenti
Risposta accettata
Arthur Roué
il 17 Lug 2020
Modificato: Arthur Roué
il 17 Lug 2020
You are printing in a loop with a line return at each step. This works :
a = input('Enter first number:');
b = input('Enter second number:');
fprintf('%d ', a:b);
fprintf('\n');
0 Commenti
Più risposte (1)
Sydney Lang
il 17 Lug 2020
Modificato: Sydney Lang
il 17 Lug 2020
I'm not quite sure what you're doing with the reshape.
Use the .' notation to transpose a matrix
x = 1
2
3
x = x.';
x = 1 2 3
0 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!