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