Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

i need some help

1 visualización (últimos 30 días)
abdalrhman khalaf
abdalrhman khalaf el 17 de Feb. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
i want to assign variable depend on anothor variable
  3 comentarios
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH el 17 de Feb. de 2020
Editada: JESUS DAVID ARIZA ROYETH el 17 de Feb. de 2020
John D'Errico
John D'Errico el 17 de Feb. de 2020
Learn to use MATLAB as a vector and array language. After all, that is how it is designed to be used.

Respuestas (1)

Bob Thompson
Bob Thompson el 17 de Feb. de 2020
Editada: Bob Thompson el 17 de Feb. de 2020
If I'm understanding what you're trying to do, you're only missing parentheses.
>> n = 10;
>> p(10) = 2;
>> p(n)
p(n) =
2
You can also assign values in a similar manner.
>> n = 10;
>> p(n) = 2;
>> p(10)
p(10) =
2
  2 comentarios
abdalrhman khalaf
abdalrhman khalaf el 17 de Feb. de 2020
Put if 0 it fails ...
Bob Thompson
Bob Thompson el 18 de Feb. de 2020
Yes, because the value inside the parentheses is referencing a position within an array. You cannot call a 0 placement, because a 0 position doesn't make sense.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by