wrote the code but the error says Unrecognized function or variable 'a'. Error in firle (line 13) Z = A(a)*B(b);
2 次查看(过去 30 天)
显示 更早的评论
x= (0:.1:5);
y= (0:.1:5);
[X,Y] = meshgrid(x,y);
for n=1:7
for m=1:7
A = @(a) (2/sqrt(a))*sin((m*pi/5)*a);
B = @(b) sin((n*pi/5)*b);
Z = A(a)*B(b);
[X,Y,Z] = meshgrid(x,y,z);
surf(x,y,Z)
end
end
0 个评论
回答(2 个)
Cris LaPierre
2020-7-30
The issue is with the line Z = A(a)*B(b);
You have not defined the variable 'a' or 'b'. That is resulting in the error you see. Did you mean to use n and m?
0 个评论
Image Analyst
2020-7-31
Perhaps you wanted this:
x = 0 : 0.1 : 5;
y = 0 : 0.1 : 5;
[X, Y] = meshgrid(x, y);
a = X(:);
b = Y(:);
numElements = numel(a);
n = linspace(1, 7, numElements)';
m = n;
A = (2 ./ sqrt(a)) .* sin((m * pi/5) .* a);
B = sin((n * pi/5) .* b);
Z = A .* B;
% Reshape from column vector into 2-D
Z = reshape(Z, length(x), length(y));
surf(X, Y, Z)
xlabel('x', 'FontSize', 18);
ylabel('y', 'FontSize', 18);
zlabel('z', 'FontSize', 18);
Riddhi, is this what you wanted?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!