Effacer les filtres
Effacer les filtres

Is it possible to combine strings and variables in a matrix?

9 vues (au cours des 30 derniers jours)
Z le 18 Juin 2013
I have a matrix A and A= [x y]. X and y are both defined by constants: 3 and 4, respectively.
Now, how do I make it so that I not only get A to show up as 3 4 but as x=3 and y=4.
I tried this A= ['x='x 'y='y] but it does not work.

Réponse acceptée

Pourya Alinezhad
Pourya Alinezhad le 18 Juin 2013
Modifié(e) : Pourya Alinezhad le 18 Juin 2013
  3 commentaires
Z le 18 Juin 2013
awesomeness. thanks
Pourya Alinezhad
Pourya Alinezhad le 18 Juin 2013
;) take the advantage

Connectez-vous pour commenter.

Plus de réponses (1)

random09983492 le 18 Juin 2013
Hi Z,
Here are 2 solutions:
1. Change:
disp [rate, duration]
disp([rate, duration])
2. Use fprintf statement instead of disp like such:
fprintf('rate = %d, duration = %d', rate, duration);
This will produce your "even better" result, I think. If not, let me know what you would like.
  1 commentaire
Z le 18 Juin 2013
This also works great! And there are spaces too. Thanks

Connectez-vous pour commenter.


En savoir plus sur Logical 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!

Translated by