meshgrid or ngrid?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have lately started to use meshgrid and ngrid thanks to the answer to my previous question. But I can not find a way to transform this code to either of them. Here on this code I have one calculationPoint, which normally has to be a meshgrid of -20:20 on both X and Y direction. Any suggestion on how to proceed would be appreciated.
clc;
S = 21;
t = linspace(-pi,pi,S);
knownPoints = [cos(t);sin(t)]; %(x,y)
f = exp(1i*t);
d = zeros (1,S);
calculationPoint = [10;9];
for idx=1:S
tmp1 = calculationPoint(1,1)-knownPoints(1,idx);
tmp2 = calculationPoint(2,1)-knownPoints(2,idx);
d(idx) = sqrt(tmp1^2+tmp2^2);
end
g = d.^2 + 1./d.^3;
z = 1/S*sum(g.*f); % z function is of parameter calculation point
0 comentarios
Respuestas (1)
KSSV
el 9 de Ag. de 2016
Your d, g are arrays of same size as t....You can use mesh grid on d/g... Are you looking for some thing like below?
clc;
S = 21;
t = linspace(-pi,pi,S);
knownPoints = [cos(t);sin(t)]; %(x,y)
f = exp(1i*t);
d = zeros (1,S);
calculationPoint = [10;9];
for idx=1:S
tmp1 = calculationPoint(1,1)-knownPoints(1,idx);
tmp2 = calculationPoint(2,1)-knownPoints(2,idx);
d(idx) = sqrt(tmp1^2+tmp2^2);
end
g = d.^2 + 1./d.^3;
[T,G] = meshgrid(t,g) ;
z = 1/S*sum(g.*f); % z function is of parameter calculation point
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!