フィルターのクリア

Why is my matrix a scalar?

5 ビュー (過去 30 日間)
Noya Linder
Noya Linder 2023 年 7 月 13 日
編集済み: Torsten 2023 年 7 月 13 日
Hi, so I've been trying to create a Z matrix to plot using "surf":
Z = [];
x = 0;
for tt = T
x = x+1;
y = 0;
for rr = R
y = y+1;
Z(x, y) = j_nu(3, R(y), T(x), R, T, dRdt);
end
end
But Z ends up being a 1X1 matrix... what did I do wrong?
  2 件のコメント
Stephen23
Stephen23 2023 年 7 月 13 日
編集済み: Stephen23 2023 年 7 月 13 日
What are T and R ? Please give us all data required to run your code.
The obvious answer is that you only allocate data once to Z, e.g. this might occur if T and R are column vectors.
Noya Linder
Noya Linder 2023 年 7 月 13 日
Yes, that was the problem. Thank you so much - I'm not used to working like this with vectors haha

サインインしてコメントする。

採用された回答

Noya Linder
Noya Linder 2023 年 7 月 13 日
編集済み: Torsten 2023 年 7 月 13 日
Hi, the problem was I needed to convert my arrays to row vectors which I did by:
R = R.';
T = T.';
I don't know if this was the smartest way to do so but it works for me so thank you Stephen23 for pointing out that issue.
Also, thank you Nandini for pointing out my way of appointing values to Z was not efficient and showing me how it should be done. Have a great evening (or morning, wherever you are)!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by