Assign values of a result to an input variable.

8 visualizaciones (últimos 30 días)
Ricardo Gutierrez
Ricardo Gutierrez el 21 de Sept. de 2019
Editada: madhan ravi el 21 de Sept. de 2019
Hello good day for everyone.
I have the following code:
% _________________________________________-
clc; clear; close all; short format
  A = rand ();
  B = rand ();
  C = rand ();
  M = [13 B 16
      A 15 17
     12 10 C];
  Q = 15 * rand (). * M;
  R = min (Q)
% ________________________________
As an example I have as a result in R:
R = 7.7191 11.0730 6.1086
As I do so that the first value( 7.7191) of vector R is assigned to variable A, the second value(11.0730 ) of vector R is assigned to B and so on, this is done "n" times within a cycle.
Thanks for your help

Respuesta aceptada

madhan ravi
madhan ravi el 21 de Sept. de 2019
Editada: madhan ravi el 21 de Sept. de 2019
That’s not a good idea, see https://in.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval . Using indexing is far more efficient and easy.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by