Creating longer linspace array from 2 linspace arrays

조회 수: 9 (최근 30일)
Trevyn Woolf
Trevyn Woolf 2022년 4월 4일
댓글: Trevyn Woolf 2022년 4월 4일
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

채택된 답변

David Hill
David Hill 2022년 4월 4일
eblend=[e1blend1;e1blend2;e1blend3];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by