Problem involving fprintf and vectors
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
kaiserlim
le 20 Nov 2015
Réponse apportée : Walter Roberson
le 20 Nov 2015
Hello, i have a little problem with my function.
Below is my function,
A=input('Input the components of a vector, separated by spaces or commas:\n','s');
vector=str2num(A);
fprintf('you entered %d\n',vector)
MATLAB gives me this results. (Let's take 1,2,3 as the example for vector)
you entered 1
you entered 2
you entered 3
you entered 4
I want the results to appear like this instead
you entered 1 2 3 4
Is there any way in doing that or there is something wrong with my function?
Thanks in advance
0 commentaires
Réponse acceptée
Walter Roberson
le 20 Nov 2015
fprintf('you entered');
fprintf(' %d',vector);
fprintf('\n');
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!