Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

i need some help

조회 수: 1 (최근 30일)
abdalrhman khalaf
abdalrhman khalaf 2020년 2월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
i want to assign variable depend on anothor variable
  댓글 수: 3
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2020년 2월 17일
편집: JESUS DAVID ARIZA ROYETH 2020년 2월 17일
John D'Errico
John D'Errico 2020년 2월 17일
Learn to use MATLAB as a vector and array language. After all, that is how it is designed to be used.

답변 (1개)

Bob Thompson
Bob Thompson 2020년 2월 17일
편집: Bob Thompson 2020년 2월 17일
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
abdalrhman khalaf
abdalrhman khalaf 2020년 2월 17일
Put if 0 it fails ...
Bob Thompson
Bob Thompson 2020년 2월 18일
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.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by