Effacer les filtres
Effacer les filtres

How do I multiply an integer with a single value from the matrix?

1 vue (au cours des 30 derniers jours)
Suleman Jalal
Suleman Jalal le 11 Juin 2019
Commenté : Suleman Jalal le 11 Juin 2019
%Start of the code
Module_Information = inputdlg ({'Thrust','Mixture Ratio','Reserve'},'Test', [1 50; 1 50; 1 50;]);
Exhaust_Veloctiy = 4 * Module_Information(1,1)
%End of the code
How do I extract "Moduel_Information(1,1)" or the "Thrust" and multiple with a integator, such as 4.
  2 commentaires
madhan ravi
madhan ravi le 11 Juin 2019
Modifié(e) : madhan ravi le 11 Juin 2019
Is it MATLAB? MATLAB doesn’t use // for comment.
Suleman Jalal
Suleman Jalal le 11 Juin 2019
Yes. It should have been a "%", instead of "//".

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 11 Juin 2019
Modifié(e) : Stephen23 le 11 Juin 2019
You need to convert the character vector (contained in the output) into numeric, e.g.:
C = inputdlg(...); % C is a cell array of character vectors!
N = str2double(C{1}) % N is numeric!
N*4
  1 commentaire
Suleman Jalal
Suleman Jalal le 11 Juin 2019
Thank you so much, the "str2double" was what I was looking. It worked.

Connectez-vous pour commenter.

Plus de réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 11 Juin 2019
Modifié(e) : KALYAN ACHARJYA le 11 Juin 2019
Here Module_Information is cell
>> whos Module_Information
Name Size Bytes Class Attributes
Module_Information 3x1 192 cell
So
Exhaust_Veloctiy =4*Module_Information{1,1}
  1 commentaire
Suleman Jalal
Suleman Jalal le 11 Juin 2019
Modifié(e) : Suleman Jalal le 11 Juin 2019
I am not sure, however the answer does not correlates with the correct output. I attached a screenshot below of my code in the comman window. Screen Shot 2019-06-11 at 1.47.52 AM.png

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by