wrote the code but the error says Unrecognized function or variable 'a'. Error in firle (line 13) Z = A(a)*B(b);
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Cris LaPierre
on 30 Jul 2020
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 Comments
Image Analyst
on 31 Jul 2020
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 Comments
See Also
Categories
Find more on Point Cloud Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!