Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

i need some help

1 Ansicht (letzte 30 Tage)
abdalrhman khalaf
abdalrhman khalaf am 17 Feb. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
i want to assign variable depend on anothor variable
  3 Kommentare
John D'Errico
John D'Errico am 17 Feb. 2020
Learn to use MATLAB as a vector and array language. After all, that is how it is designed to be used.

Antworten (1)

Bob Thompson
Bob Thompson am 17 Feb. 2020
Bearbeitet: Bob Thompson am 17 Feb. 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 Kommentare
abdalrhman khalaf
abdalrhman khalaf am 17 Feb. 2020
Put if 0 it fails ...
Bob Thompson
Bob Thompson am 18 Feb. 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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by