MATLAB Answers

How to smooth out a surf plot

2 views (last 30 days)
Tigist Beyene
Tigist Beyene on 20 Jan 2020
Answered: KSSV on 20 Jan 2020
I want a nice and smooth surface. Can someone please give me some hints ?
clear
zspan = linspace(0,2,100);
v2in_vals = linspace(0.01,0.05,10);
v0mat = [1 0.1 1];
N = size(v0mat, 1);
zsol = cell(N,1);
v1sol = cell(N,1);
v2sol = cell(N,1);
v3sol = cell(N,1);
v2in = cell(N,1);
for k=1:length(v2in_vals)
v0 = v0mat;
v0(2) = v2in_vals(k);
[z,v] = ode45(@rhs,zspan,v0);
zsol{k} = z;
v1sol{k} = v(:,1);
v2sol{k} = v(:,2);
v3sol{k} = v(:,3);
v2in{k} = v0mat(2) * ones(size(v2sol{k}));
end
all_z = [zsol{:}];
all_v2 = [v2sol{:}];
all_v2in = [v2in{:}];
v2in_vec = v2in_vals;
z_vec = all_v2(:,2);
surf(z_vec, v2in_vec, all_v2.')
xlabel('z');
ylabel('dw');
zlabel('w');
function parameters=rhs(z,v)
alpha=0.116;
db= 2*alpha-(v(1).*v(3))./(2*v(2).^2);
dw= (v(3)./v(2))-(2*alpha*v(2)./v(1));
dgmark= -0.01-(2*alpha*v(3)./v(1));
parameters=[db;dw;dgmark];
end

  0 Comments

Sign in to comment.

Answers (1)

KSSV
KSSV on 20 Jan 2020
surf(z_vec, v2in_vec, all_v2.')
Increase the dimensions of z_vec and v2in_vec. Make the difference/ step size small to increase the dimensions.

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by