當前位置:編程學習大全網 - 編程軟體 - matlab c(i,j)=i+j; i=1:100,j=1:100,要在100*100的平面上用不同顏色表示c(i,j)值的不同,顏色平滑過渡

matlab c(i,j)=i+j; i=1:100,j=1:100,要在100*100的平面上用不同顏色表示c(i,j)值的不同,顏色平滑過渡

In order to customize color order in the plot, I recommond you to use command:

>>?jet(?n?)?%?n?is?the?total?number?of?your?plots

As you should know, the color is representative by?a three-element row vector, which is the RGB value.

For example:

RGB? color

[000]|black

[110]|yellow

The automatically colorful plot is therefore all about the change of the RGB value by applying [ jet( ) ] command in Matlab.

Here is a simple example code to help you better understand the implication of this command in plot.

n?=?10;%?number

c?=?jet(n);%?color

x?=?0:.01:1;

for?i?=?1:n

y?=?x.^(1+i);

plot(x,y,'color',c(i,:));%?the?key?to?obtian

%?colorful?plot?effect!!!

hold?on

end

hold?off

For your question, the code could be written as:

clear?all

n?=?100;

[a,b]?=?meshgrid(1:n);

c?=?a?+?b;

cc?=?jet(n*n);

v?=?0;

for?i?=?1:n

for?j?=?1:n

v?=?v?+?1;

plot3(a(i,j),b(i,j),c(i,j),'o','color',cc(v,:))

hold?on

end

end

hold?off

The graphic will be displayed as

However, in my opinion your question doesn't require any excessive command to achieve your request at all.

Here is the modified code to achieve what you expect but yet facter than the previous one.

clear?all

n?=?100;

[a,b]?=?meshgrid(1:n);

c?=?a?+?b;

mesh(a,b,c)

Chance is yours!!! Cheers...

  • 上一篇:有哪些音樂節拍?
  • 下一篇:數學浪漫表白方式
  • copyright 2024編程學習大全網