How to convert csv to Heatmap?

조회 수: 22 (최근 30일)
Stride Okorie
Stride Okorie 2022년 7월 26일
편집: Vandit 2024년 9월 16일
Hello, I am relatively new to using MATLAB so I am coming across some issues. I want to convert a .csv file with A LOT of raw data and visualize it as a heatmap. It is a 36189x88 data table. This code I have so far shows something but it is not really giving me what I want. Any help or advice would be greatly appreciated.
clc;
clear
close all;
data = readtable("N303_M.2.csv");
%% Data Filtering/Processing
clc, clearvars -except data, format compact, close all
%convert from Table to Array
strain(:, 1:88) = table2array(data(:,1:88));
%% Data Visualizations
figure(1);
plot(strain(:, 1:88));
heatmap(strain(:, 1:88),'Colormap', jet,)
title('Visual Data for Mat')
  댓글 수: 1
dpb
dpb 2022년 7월 26일
Well, we're at a loss to help -- no data, not even a figure or a hint of what you might think it is you would want instead...
What would 32K x 88 data values be, even, pray tell? You've taken all of it and just mushed it together as one thing, surely there's some demarcation of what the 88 columns would be?

댓글을 달려면 로그인하십시오.

답변 (1개)

Vandit
Vandit 2024년 9월 16일
편집: Vandit 2024년 9월 16일
Hi Stride,
To visualize your large dataset as a heatmap, you can make some modifications to your existing code. Here's an updated version:
clc;
clear
close all;
data = readmatrix('N303_M.2.csv');
%% Data Filtering/Processing
clc, clearvars -except data, format compact, close all
% Data Normalization
normalizedData = (data - min(data(:))) / (max(data(:)) - min(data(:)));
% Create the heatmap
figure;
heatmap(normalizedData, 'Colormap', jet);
colorbar;
title('Visual Data for Mat');
The provided code reads data from a CSV file named "N303_M.2.csv" using 'readmatrix' function and stores it in the variable 'data'. Next, a new figure window is created, and the normalized data is used to generate a heatmap using the 'heatmap' function. The colormap is set to 'jet', which determines the color scheme of the heatmap.
To know more about 'readmatrix' and 'heatmap' function, refer to the link below:
Hope this helps.
Thankyou

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by