Using vectors to all points on a meshgrid
古いコメントを表示
I have a meshgrid across x y and z and need to produce vectors from the origin to all points in the meshgrid that can be used in an potential equation to find the potential at each point as from the origin. How would I go about doing this?
[X Y Z] = meshgrid((-4.05:0.1:4.05),(-4.05:0.1:4.05),(-4:0.1:4))
5 件のコメント
jonas
2018 年 11 月 10 日
What do you mean vectors? X Y Z already have the coordinates for each point and the other point is obviously [0 0 0]. What is the desired format?
James
2018 年 11 月 10 日
James
2018 年 11 月 10 日
編集済み: madhan ravi
2018 年 11 月 10 日
Walter Roberson
2018 年 11 月 10 日
dot() as a call does not vectorize. For real valued vectors, dot = sum(x.*y) which can be extended to arrays if you are careful about shapes and directions and replication. In some cases you can use the * operator after having arranged the right orientation.
Bruno Luong
2018 年 11 月 10 日
"dot() as a call does not vectorize."
Not true:
>> y=rand(3,4)
y =
0.751267059305653 0.699076722656686 0.547215529963803 0.257508254123736
0.255095115459269 0.890903252535798 0.138624442828679 0.840717255983663
0.505957051665142 0.959291425205444 0.149294005559057 0.254282178971531
>> x=rand(size(y))
x =
0.814284826068816 0.349983765984809 0.616044676146639 0.830828627896291
0.243524968724989 0.196595250431208 0.473288848902729 0.585264091152724
0.929263623187228 0.251083857976031 0.351659507062997 0.549723608291140
>> dot(x,y)
ans =
1.144034879739528 0.660675444113866 0.455219273317489 0.845771767133647
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!