matlab画出相关性分析图
时间: 2023-08-16 15:04:02 浏览: 355
在MATLAB中,可以使用heatmap函数来绘制相关性分析图。首先,加载数据并计算维度之间的相关系数。然后,使用heatmap函数绘制热图,并设置相关参数。最后,保存图片。以下是MATLAB代码示例:
```matlab
% 加载数据
data_load = dlmread('E:\scanplot\wine.data');
data = data_load(:,2:14);
\[N, D\] = size(data);
% 求维度之间的相关系数
rho = corr(data, 'type', 'pearson');
% 绘制热图
string_name = {'Alcohol','Malic acid','Ash','Alcalinity of ash','Magnesium','Total phenols','Flavanoids','Nonflavanoid phenols','Proanthocyanins','Color intensity','Hue','Diluted wines','Proline'};
xvalues = string_name;
yvalues = string_name;
h = heatmap(xvalues, yvalues, rho, 'FontSize', 10, 'FontName', 'Times New Roman');
h.Title = 'Correlation Coefficient';
colormap(jet)
% 保存图片
saveas(gcf, sprintf('wine相关系数热图.jpg'), 'bmp');
```
这段代码会加载数据,计算相关系数,并绘制出相关性分析的热图。最后,将图片保存为"wine相关系数热图.jpg"。
#### 引用[.reference_title]
- *1* *2* [matlab相关性分析](https://blog.csdn.net/luxurie/article/details/109697239)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [matlab画heatmap相关图](https://blog.csdn.net/Electrical_IT/article/details/114820755)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文