Using vectors to all points on a meshgrid
Mostrar comentarios más antiguos
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 comentarios
jonas
el 10 de Nov. de 2018
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
el 10 de Nov. de 2018
James
el 10 de Nov. de 2018
Editada: madhan ravi
el 10 de Nov. de 2018
Walter Roberson
el 10 de Nov. de 2018
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
el 10 de Nov. de 2018
"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
Respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!