meshgrid values to function without loop
古いコメントを表示
Hello, i want to give x,y coordinates to a self-written function. The current state is, that i use 2 loops. I think that this is a very ugly and computation consuming solution. Can someone help me to improve this?
x = linspace(0,1,11) ;
y = linspace(0,1,11) ;
[X,Y] = meshgrid(x,y) ;
for kk = 1:11
for nn = 1:11
Coordinate = [X(kk,nn) Y(kk,nn)];
Z(kk,nn) = f_SomeFunction(Coordinate,someConstant,...);
end
end
4 件のコメント
madhan ravi
2019 年 1 月 30 日
編集済み: madhan ravi
2019 年 1 月 30 日
Coordinate = [X Y] % doesn't this do what you want? without loop?
Nimananda Sharma
2019 年 1 月 30 日
Hi,
It appears that your function accepts only scalar input
One possible solution would to change your function to use maxtrix?
Christopher Brokmann
2019 年 1 月 30 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!