MATLAB | 有关数值矩阵、颜色图及颜色列表的技巧整理

这篇具有很好参考价值的文章主要介绍了MATLAB | 有关数值矩阵、颜色图及颜色列表的技巧整理。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

这是一篇有关数值矩阵、颜色矩阵、颜色列表的技巧整合,会以随笔的形式想到哪写到哪,可能思绪会比较飘逸请大家见谅,本文大体分为以下几个部分:

  • 数值矩阵用颜色显示
  • 从颜色矩阵提取颜色
  • 从颜色矩阵中提取数据
  • 颜色列表相关函数
  • 颜色测试图表的识别

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

数值矩阵用颜色显示

heatmap

我们最常用的肯定就是heatmap函数显示数值矩阵:

X=rand(10);
heatmap(X);

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言
字体颜色可设置为透明:

X=rand(10);
HM=heatmap(X);
HM.CellLabelColor='none';

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

如果由NaN值,会显示为黑色:

X=rand(10);
X([3,4,15])=nan;
HM=heatmap(X);
HM.CellLabelColor='none';

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

这个颜色也可以改,比如改成浅灰色:

X=rand(10);
X([3,4,15])=nan;
HM=heatmap(X);
HM.CellLabelColor='none';
HM.MissingDataColor=[.8,.8,.8];

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

imagesc

imagesc随便加个colorbar就和heatmap非常像了,而且比较容易进行图像组合(heatmap的父类不能是axes),但是没有边缘:

X=rand(10);
imagesc(X)
colormap(winter)
colorbar

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

比较烦的是imagesc即使数据有NaN也会对其进行插值显示,好坏参半吧。

另外随便写了点代码发现MATLAB自带的幻方绘制挺有规律的hiahiahia:

for i=1:16
    ax=subplot(4,4,i);
    hold on;axis tight off equal
    X=magic(3+i);
    imagesc(X);
end

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

image

image函数单通道时也可以设置colormap来进行颜色映射:

load spine
image(X)
colormap(map) 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

pcolor

pcolor由于每个方块颜色都会使用左上角的数值来计算,因此会缺一行一列,我们可以补上一行一列nan:

X=rand(6);
X(end+1,:)=nan;
X(:,end+1)=nan;
pcolor(X);
colormap(winter)
colorbar 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

可修饰的东西就比较丰富了,比如边缘颜色:

X=rand(6);
X(end+1,:)=nan;
X(:,end+1)=nan;
pHdl=pcolor(X);
pHdl.EdgeColor=[1,1,1];
pHdl.LineWidth=2;
colormap(winter)
colorbar 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

气泡图

气泡图大概也能冒充一下热图:

Z=rand(7);
[X,Y]=meshgrid(1:size(Z,2),1:size(Z,1));

bubblechart(X(:),Y(:),Z(:),Z(:),'MarkerFaceAlpha',.6) 
colormap(parula)
colorbar
set(gca,'XTick',1:size(Z,2),'YTick',1:size(Z,1),'LineWidth',1,...
    'XGrid','on','YGrid','on','FontName','Cambria','FontSize',13)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

随便写着玩

虽然surf函数调整视角也像是热图的样子,但是不打算讲了,反而等高线填充图虽然不像热图但是很有意思,感觉可以当作colormap展示的示例图:

X=rand(10);
CF=contourf(X);
colormap(winter)
colorbar 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

从颜色矩阵提取颜色

像素提取器

需要安装:
Image Processing Toolbox
图像处理工具箱.

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

使用以下代码可以显示每个像素RGB值:

imshow('peppers.png')
impixelregion 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

图片颜色统计小函数

我写过一个RGB颜色统计图绘制函数:

function HistogramPic(pic)
FreqNum=zeros(size(pic,3),256);
for i=1:size(pic,3)
    for j=0:255
        FreqNum(i,j+1)=sum(sum(pic(:,:,i)==j));
    end
end
ax=gca;hold(ax,'on');box on;grid on
if size(FreqNum,1)==3
    bar(0:255,FreqNum(1,:),'FaceColor',[0.6350 0.0780 0.1840],'FaceAlpha',0.5);
    bar(0:255,FreqNum(2,:),'FaceColor',[0.2400 0.5300 0.0900],'FaceAlpha',0.5);
    bar(0:255,FreqNum(3,:),'FaceColor',[0      0.4470 0.7410],'FaceAlpha',0.5);
    ax.XLabel.String='RGB brightness';
    rrange=[num2str(min(pic(:,:,1),[],[1,2])),' , ',num2str(max(pic(:,:,1),[],[1,2]))];
    grange=[num2str(min(pic(:,:,2),[],[1,2])),' , ',num2str(max(pic(:,:,2),[],[1,2]))];
    brange=[num2str(min(pic(:,:,3),[],[1,2])),' , ',num2str(max(pic(:,:,3),[],[1,2]))];
    legend({['R: range[',rrange,']'],['G: range[',grange,']'],['B: range[',brange,']']},...
             'Location','northwest','Color',[0.9412    0.9412    0.9412],...
             'FontName','Cambria','LineWidth',0.8,'FontSize',11);
else 
    bar(0:255,FreqNum(1,:),'FaceColor',[0.50 0.50 0.50],'FaceAlpha',0.5);
    ax.XLabel.String='Gray scale';
    krange=[num2str(min(pic(:,:,1),[],[1,2])),' , ',num2str(max(pic(:,:,1),[],[1,2]))];
    legend(['Gray: range[',krange,']'],...
           'Location','northwest','Color',[0.9412    0.9412    0.9412],...
           'FontName','Cambria','LineWidth',0.8,'FontSize',11);
end
ax.LineWidth=1;
ax.GridLineStyle='--';
ax.XLim=[-5 255];
ax.XTick=[0:45:255,255];
ax.YLabel.String='Frequency number';
ax.FontName='Cambria';
ax.FontSize=13;
end

非常简单的使用方法,就是读取图片后调用函数即可:

pic=imread('test.png');
HistogramPic(pic)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

若图像为灰度图则效果如下:

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

色卡生成器

从图片中提取主要颜色:https://mp.weixin.qq.com/s/Pj6t0SMDBAjQi3ecj6KVaA

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

颜色提取器

推荐两款颜色提取器,一款免费一款付费:

免费版:https://mp.weixin.qq.com/s/uIyvqQa9Vnz7gYLgd7lUtg

付费版:https://mp.weixin.qq.com/s/BpegP7CpOQERwrUXHexsGQ

从颜色矩阵中提取数据

之前写过一列把热图变为数值矩阵的函数,可以去瞅一眼:https://mp.weixin.qq.com/s/wzqCCFF2yvC80-ruqMKOpQ

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

颜色列表相关函数

颜色方块展示函数

写了个用来显示颜色的小函数:

function colorSwatches(C,sz)
ax=gca;hold on;
ax.YDir='reverse';
ax.XColor='none';
ax.YColor='none';
ax.DataAspectRatio=[1,1,1];
for i=1:sz(1)
    for j=1:sz(2)
        if j+(i-1)*sz(2)<=size(C,1)
            fill([-.4,-.4,.4,.4]+j,[-.4,.4,.4,-.4]+i,C(j+(i-1)*sz(2),:),...
                'EdgeColor','none')
        end
    end
end
end

使用方式(第一个参数是颜色列表,第二个参数是显示行列数):

C=lines(7);
colorSwatches(C,[3,3]) 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

C=[0.6471         0    0.1490
    0.7778    0.1255    0.1516
    0.8810    0.2680    0.1895
    0.9569    0.4275    0.2627
    0.9804    0.5974    0.3412
    0.9935    0.7477    0.4418
    0.9961    0.8784    0.5647
    0.9987    0.9595    0.6876
    0.9595    0.9843    0.8235
    0.8784    0.9529    0.9725
    0.7399    0.8850    0.9333
    0.5987    0.7935    0.8824
    0.4549    0.6784    0.8196
    0.3320    0.5320    0.7438
    0.2444    0.3765    0.6654
    0.1922    0.2118    0.5843];
colorSwatches(C,[4,4]) 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

插值

要是自己准备的颜色列表颜色数量少可能会不连续:

XData=rand(15,15);
XData=XData+XData.';
H=fspecial('average',3);
XData=imfilter(XData,H,'replicate');

imagesc(XData)
CM=[0.6196    0.0039    0.2588
    0.8874    0.3221    0.2896
    0.9871    0.6459    0.3636
    0.9972    0.9132    0.6034
    0.9300    0.9720    0.6398
    0.6319    0.8515    0.6437
    0.2835    0.6308    0.7008
    0.3686    0.3098    0.6353];
colormap(CM)
colorbar
hold on
ax=gca;
ax.DataAspectRatio=[1,1,1];

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

可以对其进行插值:

rng(24)
XData=rand(15,15);
XData=XData+XData.';
H=fspecial('average',3);
XData=imfilter(XData,H,'replicate');

imagesc(XData)
CM=[0.6196    0.0039    0.2588
    0.8874    0.3221    0.2896
    0.9871    0.6459    0.3636
    0.9972    0.9132    0.6034
    0.9300    0.9720    0.6398
    0.6319    0.8515    0.6437
    0.2835    0.6308    0.7008
    0.3686    0.3098    0.6353];
CMX=linspace(0,1,size(CM,1));
CMXX=linspace(0,1,256)';
CM=[interp1(CMX,CM(:,1),CMXX,'pchip'),interp1(CMX,CM(:,2),CMXX,'pchip'),interp1(CMX,CM(:,3),CMXX,'pchip')];
colormap(CM)
colorbar
hold on
ax=gca;
ax.DataAspectRatio=[1,1,1];

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

colormap编辑器

colormapeditor 

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

编辑完可以另存工作区,之后存为mat文件:

save CM.mat CustomColormap

之后画图就可以用啦:

rgbImage=imread("peppers.png");
imagesc(rgb2gray(rgbImage))

load CM.mat
colormap(CustomColormap)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

colormap显示

Steve Eddins大佬写了个美观的colormap展示器

Steve Eddins (2023). Colormap Test Image (https://www.mathworks.com/matlabcentral/fileexchange/63726-colormap-test-image), MATLAB Central File Exchange. 检索来源 2023/2/13.

function I = colormapTestImage(map) 
% colormapTestImage Create or display colormap test image.
%   I = colormapTestImage creates a grayscale image matrix that is useful
%   for evaluating the effectiveness of colormaps for visualizing
%   sequential data. In particular, the small-amplitude sinusoid pattern at
%   the top of the image is useful for evaluating the perceptual uniformity
%   of a colormap.
%
%   colormapTestImage(map) displays the test image using the specified
%   colormap. The colormap can be specified as the name of a colormap
%   function (such as 'parula' or 'jet'), a function handle to a colormap
%   function (such as @parula or @jet), or a P-by-3 colormap matrix.
%
%   EXAMPLES
%
%     Compute the colormap test image and save it to a file.
%
%       mk = colormapTestImage;
%       imwrite(mk,'test-image.png');
%
%     Compare the perceptual characteristics of the parula and jet
%     colormaps.
%
%       colormapTestImage('parula')
%       colormapTestImage('jet')
%
%   NOTES
%
%   The image is inspired by and adapted from the test image proposed in
%   Peter Kovesi, "Good Colour Maps: How to Design Them," CoRR, 2015,
%   https://arxiv.org/abs/1509.03700
%
%   The upper portion of the image is a linear ramp (from 0.05 to 0.95)
%   with a superimposed sinusoid. The amplitude of the sinusoid ranges from
%   0.05 at the top of the image to 0 at the bottom of the upper portion.
%
%   The lower portion of the image is a pure linear ramp from 0.0 to 1.0.
%
%   This test image differs from Kovesi's in three ways:
%
%     (a) The Kovesi test image superimposes a sinusoid on top of a
%     full-range linear ramp (0 to 1). It then rescales each row
%     independently to have full range, resulting in a linear trend slope
%     that slowly varies from row to row. The modified test image uses the
%     same linear ramp (0.05 to 0.95) on each row, with no need for
%     rescaling.
%
%     (b) The Kovesi test image has exactly 64 sinusoidal cycles
%     horizontally. This test image has 64.5 cycles plus one sample. With
%     this modification, the sinusoid is at the cycle minimum at the left
%     of the image, and it is at the cycle maximum at the right of the
%     image. With this modification, the top row of the modified test image
%     varies from exactly 0.0 on the left to exactly 1.0 on the right,
%     without rescaling.
%
%     (c) The modified test image adds to the bottom of the image a set of
%     rows containing a full-range (0.0 to 1.0) linear ramp with no
%     sinusoidal variation. That makes it easy to view how the colormap
%     appears with a full-range linear ramp.
%
%   Reference: Peter Kovesi, "Good Colour Maps: How to Design Them,"
%   CoRR, 2015, https://arxiv.org/abs/1509.03700

%   Steve Eddins
%   Copyright 2017 The MathWorks, Inc.

% Compare with 64 in Kovesi 2015. Adding a half-cycle here so that the ramp
% + sinusoid will be at the lowest part of the cycle on the left side of
% the image and at the highest part of the cycle on the right side of the
% image.
num_cycles = 64.5;

if nargin < 1
    I = testImage(num_cycles);
else
    displayTestImage(map,num_cycles)
end

function I = testImage(num_cycles)

pixels_per_cycle = 8;
A = 0.05;

% Compare with width = pixels_per_cycle * num_cycles in Kovesi 2015. Here,
% the extra sample is added to fully reach the peak of the sinusoid on the
% right side of the image.
width = pixels_per_cycle * num_cycles + 1;

% Determined by inspection of 
% http://peterkovesi.com/projects/colourmaps/colourmaptest.tif
height = round((width - 1) / 4);

% The strategy for superimposing a varying-amplitude sinusoid on top of a
% ramp is somewhat different from Kovesi 2015. For each row of the test
% image, Kovesi adds the sinusoid to a full-range ramp and then rescales
% the row so that ramp+sinusoid is full range. A benefit of this approach
% is that each row is full range. A drawback is that the linear trend of
% each row varies as the amplitude of the superimposed sinusoid changes.
%
% Our approach here is a modification. The same linear ramp is used for
% every row of the test image, and it goes from A to 1-A, where A is the
% amplitude of the sinusoid. That way, the linear trend is identical on
% each row. The drawback is that the bottom of the test image goes from
% 0.05 to 0.95 (assuming A = 0.05) instead of from 0.00 to 1.00.
ramp = linspace(A, 1-A, width);

k = 0:(width-1);
x = -A*cos((2*pi/pixels_per_cycle) * k);

% Amplitude of the superimposed sinusoid varies with the square of the
% distance from the bottom of the image.
q = 0:(height-1);
y = ((height - q) / (height - 1)).^2;
I1 = (y') .* x;

% Add the sinusoid to the ramp.
I = I1 + ramp;

% Add region to the bottom of the image that is a full-range linear ramp.
I = [I ; repmat(linspace(0,1,width), round(height/4), 1)];

function displayTestImage(map,num_cycles)

name = '';
if isstring(map)
    map = char(map);
    name = map;
    f = str2func(map);
    map = f(256);
elseif ischar(map)
    name = map;
    f = str2func(map);
    map = f(256);
elseif isa(map,'function_handle')
    name = func2str(map);
    map = map(256);
end

I = testImage(num_cycles);
[M,N] = size(I);

% Display the image with a width of 2mm per cycle.
display_width_cm = num_cycles * 2 / 10;
display_height_cm = display_width_cm * M / N;

fig = figure('Visible','off',...
    'Color','k');
fig.Units = 'centimeters';

% Figure width and height will be image width and height plus 2 cm all the
% way around.
margin = 2;
fig_width = display_width_cm + 2*margin;
fig_height = display_height_cm + 2*margin;
fig.Position(3:4) = [fig_width fig_height];

ax = axes('Parent',fig,...
    'DataAspectRatio',[1 1 1],...
    'YDir','reverse',...
    'CLim',[0 1],...
    'XLim',[0.5 N+0.5],...
    'YLim',[0.5 M+0.5]);
ax.Units = 'centimeters';
ax.Position = [margin margin display_width_cm display_height_cm];
ax.Units = 'normalized';
box(ax,'off')

im = image('Parent',ax,...
    'CData',I,...
    'XData',[1 N],...
    'YData',[1 M],...
    'CDataMapping','scaled');

if ~isempty(name)
    title(ax,name,'Color',[0.8 0.8 0.8],'Interpreter','none')
end

% Draw scale line.
pixels_per_centimeter = N / (display_width_cm);
x = [0.5 5*pixels_per_centimeter];
y = (M + 30) * [1 1];
line('Parent',ax,...
    'XData',x,...
    'YData',y,...
    'Color',[0.8 0.8 0.8],...
    'Clipping','off');
text(ax,mean(x),y(1),'5cm',...
    'VerticalAlignment','top',...
    'HorizontalAlignment','center',...
    'Color',[0.8 0.8 0.8]);

colormap(fig,map)

fig.Visible = 'on';

用的时候就正常后面放颜色列表就行:

colormapTestImage(jet)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

有趣实例

Ned Gulley大佬在迷你黑客大赛有趣的数据分析中给出的图片,展示了各种colormap使用频率排行:

https://blogs.mathworks.com/community/2022/11/08/minihack2022/?s_tid=srchtitle_minihack_1&from=cn

没提供完整代码我自己写了个:

cmaps={'jet','hot','hsv','gray','copper','colorcube','turbo','bone','lines'};
props=[.75,.69,.68,.4,.33,.32,.3,.3,.27];

ax=gca;hold on
ax.XLim=[0,max(props)];
ax.YLim=[.3,1.3*length(cmaps)+1];
ax.YTick=(1:length(cmaps)).*1.3;
ax.YTickLabel=cmaps;
ax.YDir='reverse';
for i=1:length(cmaps)
    c=eval(cmaps{i});
    c=reshape(c,1,size(c,1),3);
    image([0,props(i)],[i,i].*1.3,c);
    rectangle('Position',[0 i.*1.3-.5,props(i) 1])
end

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

rgbplot

统计colormap中RGB值变化:

rgbplot(parula)
hold on
colormap(parula)
colorbar('Ticks',[])

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言
修饰一下能好看点:

rgbplot(parula)
hold on
colormap(parula)
colorbar('Ticks',[])

ax=gca;hold on;axis tight
set(ax,'XMinorTick','on','YMinorTick','on','FontName','Cambria',...
    'XGrid','on','YGrid','on','GridLineStyle','-.','GridAlpha',.1,'LineWidth',.8);
lHdl=findobj(ax,'type','line');
for i=1:length(lHdl)
    lHdl(i).LineWidth=2;
end

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

颜色测试图表的识别

需要安装:
Image Processing Toolbox
图像处理工具箱.

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

首先展示一下示例图片:

I=imread("colorCheckerTestImage.jpg");
imshow(I)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

检测并进行位置标注:

chart=colorChecker(I);
displayChart(chart)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

四个角点位置:

chart.RegistrationPoints

ans =
1.0e+03 *

1.3266 0.8282
0.7527 0.8147
0.7734 0.4700
1.2890 0.4632

展示检测颜色:

colorTable=measureColor(chart)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

展示标准颜色和检测颜色差别:

figure
displayColorPatch(colorTable)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言

绘制CIE 1976 L* a* b*颜色空间中的测量和参考颜色对比:

figure
plotChromaticity(colorTable)

matlab颜色矩阵,# MATLAB 笔记,matlab,矩阵,开发语言文章来源地址https://www.toymoban.com/news/detail-780553.html

到了这里,关于MATLAB | 有关数值矩阵、颜色图及颜色列表的技巧整理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • MATLAB 之 数值数据,矩阵的表示和变量及其操作

    MATLAB 数据类型较为丰富,既有数值型、字符串等基本数据类型,又有结构(Structure)、单元(Cell)等复杂的数据类型。 在 MATLAB 中,没有专门的逻辑型数据,而以数值 1 (非零)表示真,以数值 0 表示假。 MATLAB 各种数据类型都以矩阵形式存在,所以矩阵是 MATLAB 最基本的数据

    2024年02月04日
    浏览(35)
  • matlab 二阶导(海森矩阵)的数值计算(附代码和示例)

    海森矩阵中就是单值函数对自变量(可以是向量,如 x = [ x 1 , x 2 , x 3 , . . . ] mathbf{x}=[x_1,x_2,x_3,...] x = [ x 1 ​ , x 2 ​ , x 3 ​ , ... ] )的二阶导数: 其中元素,如G的第一行第二列元素的定义如下: 可以看出是两个一阶导数的差再除以一个微小增量。如果 x mathbf{x} x 是个二元

    2024年02月03日
    浏览(39)
  • Python-scatter散点图及颜色大全

    效果 rcParams rcParams用来设置画图时的一些基本参数 scatter matplotlib.pyplot.scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, data=None, **kwargs) x,y——设置点的位置 s——点的大小 c——点的颜色 marker——点的形状 cmap—

    2024年02月02日
    浏览(27)
  • 【数值分析】用幂法计算矩阵的主特征值和对应的特征向量(附matlab代码)

    用幂法计算下列矩阵的按模最大特征值及对应的特征向量 k= 1 V^T= 8 6 0 m= 8 u^T= 1.0000 0.7500 0 k= 2 V^T= 9.2500 6.0000 -2.7500 m= 9.2500 u^T= 1.0000 0.6486 -0.2973 k= 3 V^T= 9.5405 5.8919 -3.5405 m= 9.5405 u^T= 1.0000 0.6176 -0.3711 k= 4 V^T= 9.5949 5.8414 -3.7309 m= 9.5949 u^T= 1.0000 0.6088 -0.3888 k= 5 V^T= 9.6041 5.8240 -3.7753 m=

    2024年02月01日
    浏览(32)
  • 【MATLAB】matlab曲线拟合与矩阵计算技巧

    目录 1.曲线拟合定义 2.数据预处理 3.数据拟合 4.数据拟合matlab编程例子 5.数据拟合函数表 6.matlab中常用插值方法 7.矩阵的特征值分解         在实际工程应用和科学实践中,经常需要寻求两个(或多个)变量间的关系,而实际去只能 通过观测得到一些离散的数据点。针对这

    2024年02月02日
    浏览(36)
  • Matlab如何删除矩阵中的零元素,重新整理不等行的矩阵

     现在我有的是一个50行,1832列的矩阵,但是其每一列上有效的数字并不多,且不相等,其余都是没用的0元素。那么如何删除矩阵中的零元素,重新整理不等行的矩阵?先上结论。 结论:最方便的还是转化成Cell矩阵,因为只有这样,每一列可以存储不等长度的(自由的)数

    2024年02月11日
    浏览(34)
  • 5.2 构造数值积分公式的基本方法与有关概念的例题分析

      确定求积公式 中的系数,使其具有尽可能高的代数精度。 我的答案: 一、信息 1.给了我一个求积公式 2.确定求积公式中的系数 3.使得这个求积系数具有尽可能高的代数精度。 二、分析 条件1:告诉我这个求积公式具体有3个未知量 条件2:告诉我此次问题解答的目标1是确定

    2024年02月01日
    浏览(36)
  • MATLAB | 绘图复刻(九) | 泰勒图及组合泰勒图

    有粉丝问我这个图咋画: 我一看,这不就泰勒图嘛,就fileexchange上搜了一下泰勒图绘制代码,但是有的代码比较新的版本运行要改很多地方,有的代码需要包含一些压缩包没并没有的别人写的函数,于是我干脆自己写了个工具,想着如果大家用其他泰勒图绘制代码来不及修改

    2024年02月08日
    浏览(27)
  • echarts动态渲染柱状图背景颜色以及顶部数值

     众所周知 柱状图的背景色在series下的 itemStyle 的color下修改  不同数据让每个柱状图背景颜色不同  这个时候就需要自定义  所以我在color后跟了一个箭头函数  里面的参数params跟formatter里的是一样的  可以打印出来 看下里面有什么值  我打印了一下  所以这个时候就可以根

    2024年02月04日
    浏览(38)
  • 有关3dmax对齐技巧的那些事

    建模操作中,对齐是非常常用的一个功能,用好这个对齐功能能够事半功倍,好处我不说了,下面我们这篇博文就来说说3dmax对齐技巧的相关的内容。 原文出处: https://blog.csdn.net/haigear/article/details/129461768 样条线中的点对齐很容易,直接使用对齐工具即可完成,点选操作点后

    2024年02月15日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包