How to colormap different functions with one gradient?

1 visualizzazione (ultimi 30 giorni)
So carefully I prepared this piecewise function:
u = 0:0.01:2*pi;
v = 2*pi:0.01:4*pi;
w = 4*pi:0.01:6*pi;
f = 1+sin(3*u); %prepare image of first plot
c = -0.2;
a = exp(-(c*2*pi+2*pi));
g = a*exp(c*v+2*pi); %prepare image of second plot
A = a*exp(c*4*pi+2*pi);
h = A+A*sin(3*w); %prepare image of third plot
hold all
grid on
How do I add a total gradient? One plot I can handle but more are challenging me.
  2 Commenti
Niklas Kurz
Niklas Kurz il 2 Feb 2021
Modificato: Niklas Kurz il 2 Feb 2021
Kinda: in general applying a total colormap over whole plot

Accedi per commentare.

Risposte (1)

Niklas Kurz
Niklas Kurz il 2 Feb 2021
Modificato: Niklas Kurz il 2 Feb 2021
So I found a sneaky workaround: just bring it in 3D and apply a simple command
[u,x] = meshgrid(0:0.01:2*pi);
ux = 1+sin(3.*x);
hold on
[v,y] = meshgrid(2*pi:0.01:4*pi,0:0.01:2*pi);
vy = a*exp(c*v+2*pi);
hold on
[w,z] = meshgrid(4*pi:0.01:6*pi,0:0.01:2*pi);
wz = A+A*sin(3*w);
shading interp
From side this looks like a twodimensional plot. Wouldn't have to perform all these tricks IF MATLAB WOULD JUST BRING colormap command for 2D plots. I don't freaking understand why they don't.


Scopri di più su Colormaps in Help Center e File Exchange



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by