フィルターのクリア

Simple problem yet I cannot find the error

1 回表示 (過去 30 日間)
Matt
Matt 2015 年 10 月 13 日
編集済み: David Young 2015 年 10 月 13 日
Here is my script:
haut=0.5
larg=0.5
long=2
A=linspace(1, larg*100, larg*100)'; % y
B=linspace(1, long*100, long*100)'; % x
C=linspace(1, haut*100, haut*100); % z
D=zeros(length(B),length(A));
for i=1:length(B)
for j=1:length(A)
D(i, j)=[B(i), A(j)]
end
end
But this doesn't work. Any suggestion?
  1 件のコメント
David Young
David Young 2015 年 10 月 13 日
編集済み: David Young 2015 年 10 月 13 日
You can't store a 2-element vector (in this case [B(i), A(j)]) in an element of a numeric array. The value assigned to D(i,j) must be a scalar.
You need to explain what you want to do - what should D contain at the end of the loop?
It's possible that you need to look at cell arrays, which can contain vectors, but it might be better in various ways to stick with numeric arrays if the problem structure is suitable.
It's also possible that meshgrid and ndgrid could help here - that's just a guess on my part though.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by