i need some help
Info
This question is closed. Reopen it to edit or answer.
Show older comments
i want to assign variable depend on anothor variable
3 Comments
abdalrhman khalaf
on 17 Feb 2020
JESUS DAVID ARIZA ROYETH
on 17 Feb 2020
Edited: JESUS DAVID ARIZA ROYETH
on 17 Feb 2020
John D'Errico
on 17 Feb 2020
Learn to use MATLAB as a vector and array language. After all, that is how it is designed to be used.
Answers (1)
Bob Thompson
on 17 Feb 2020
Edited: Bob Thompson
on 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 Comments
abdalrhman khalaf
on 17 Feb 2020
Bob Thompson
on 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.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!