Filled Contour Plot Error
Mostra commenti meno recenti
I have some functions with asymptotes and I want to get filled contour plot.
For example;

When I plot the function 3D and rotate it, I get:

First Method using fcontour
figure (1)
func=@(x,t) (16/3).*(12.*((-4)+4.*exp(1).^(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
fsurf(@(x,t) func(x,t),[-1 1 -1 1],'ShowContours','on');
zlim([-50,50]);
caxis([-50,50]);
colorbar;
colormap jet;
xlabel('x');
ylabel('t');

Second Method using contourf
figure (2)
[X, T] = meshgrid(linspace(-1,1), linspace(-1,1));
F=func(X,T);
contourf(X,T,F);
zlim([-50,50]);
caxis([-50,50]);
colorbar;
colormap jet;
xlabel('x');
ylabel('t');

As you see the colors in the last two figures are different from the first figure.
How to get the correct filled contour plots by automatically selecting appropriate contour levels for any functions?
Risposta accettata
Più risposte (1)
func=@(x,t) (16/3).*(12.*((-4)+4.*exp(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
syms x t
fun(x,t) = simplify(func(x,t))
figure
fsurf(fun, [-1 1 -1 1]);
view([0 90]); caxis([-50 50]); colorbar(); colormap(jet)
figure
fsurf(fun, [-1 1 -1 1], 'showcontours', true)
view([0 90]); caxis([-50 50]); colorbar(); colormap(jet)
figure
fsurf(func, [-1 1 -1 1],'showcontours', true)
view([0 90]); caxis([-50 50]); colorbar(); colormap(jet)
figure
[X, T] = meshgrid(linspace(-1,1), linspace(-1,1));
F=func(X,T);
contourf(X, T, F, -50:10:50);
caxis([-50 50]); colorbar(); colormap(jet)
The white in the bottom right corner is a section with F less than the lowest contour.
Categorie
Scopri di più su Contour Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






