Creating longer linspace array from 2 linspace arrays

9 visualizaciones (últimos 30 días)
Trevyn Woolf
Trevyn Woolf el 4 de Abr. de 2022
Comentada: Trevyn Woolf el 4 de Abr. de 2022
Hello, This is my first time asking a question on here! I'm struggling to find anyone trying to do what I'm doing so hoping someone can help.
Bit of background: I have some surfaces for a project and I want to create custom colormaps for them. That was fine when I was doing a gradient between 2 colours however now to fit with a colour scheme I'm wanting a gradient of 4 colours. Below is what I've been using for 2 colours
len=100;
LightB =[18, 198, 239]/255;
DarkB =[10, 42, 211]/255;
colour_blues = [linspace(DarkB(1),LightB(1),len)',linspace(DarkB(2),LightB(2),len)',linspace(DarkB(3),LightB(3),len)'];
colormap(colour_blues)
Works great but now I'm wanting to use the following colours in that order
Peach = [255, 102, 99]/255;
Green = [147, 229, 171]/255;
LightB =[18, 198, 239]/255;
DarkB =[10, 42, 211]/255;
My current thought process is to create 3 of these linspace arrays (for each RGB element) as the blends between the individual colours and then stick them together one on top of each other, hence the title. Here is where I'm at:
len=99;
Peach = [255, 102, 99]/255;
Green = [147, 229, 171]/255;
LightB =[18, 198, 239]/255;
DarkB =[10, 42, 211]/255;
e1blend1=linspace(Peach(1),Green(1),len/3)';
e1blend2=linspace(Green(1),LightB(1),len/3)';
e1blend2=linspace(LightB(1),DarkB(1),len/3)';
% etc ...
So basically I want to create a new array where the elements of e1bend1 are elements 1-33, e1bend2 are elements 34-67 and so on.
Can anyone let me know if there is a way of doing this? or better yet an easier solution to create a 4 colour gradient for a colormap! TIA

Respuesta aceptada

David Hill
David Hill el 4 de Abr. de 2022
eblend=[e1blend1;e1blend2;e1blend3];

Más respuestas (0)

Categorías

Más información sobre Orange en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by