how to keep a variable constant and other variable will change between two variable in the same code?

4 views (last 30 days)
( I'm new here. If I make any mistake, please consider it.)
I got my solution with two variable. I want to draw 3D curve. where it holds two conditions.
1) Where a and b both are constant. I did this code:
x=0:.01:2;
y=0:.01:2;
b=0.5;[X, Y]=meshgrid(x, y);
uxy=zeros(size(X));
a=1;
m=a^2;
pn=(16*m*sinh(pi*Y/2*a).*cos(pi*X/2*a))/(pi^3*sinh(pi*b/2));
uxy=(m- X.^2)/2-pn;
surf(X, Y,uxy)
Is it right or wrong? If not, then how can I do it?
2) I want to keep b as a constant. but var=a will change. I did this code:
x=0:.01:2;
y=0:.01:2;
b=0.5;
[X, Y] = meshgrid(x, y);
uxy=zeros(size(X));
for a=1:2
m=a^2;
pn=(16*m*sinh(pi*Y/2*a).*cos(pi*X/2*a))/(pi^3*sinh(pi*b/2));
uxy=(m- X.^2)/2-pn;
end
surf(X, Y, uxy)
Is it right or wrong? if not, then how can I do it?

Answers (0)

Categories

Find more on Fit Postprocessing 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!