Clear Filters
Clear Filters

i'm creating a graphic with contourf. And I wanted to correct the scale, by making X and Y referring to 2 files with the right scale.

1 view (last 30 days)
Everything works, except the scale, it was not good so I want to say to my programm :
Use Excor.csv and Emcor.csv as abscissa and ordinate for the graphic. But for some reasons it won't work, Emcor and Excor are a multiple line * 2 coloms and the other files are multiple lines * multiples coloms files. I know it's a problem, so I added r=th meshgrid thing to correct it but it won't work.
Here is my whole program :
Everything that is in Black like that : Black is something that I added to correct the scale problem.
function plot_EEM_post_treatment(~)
addpath('C:\Users\antonin.gauchy\Documents\Antonin\Matlab Antonin\Script');
% Plot EEM post treatment data
% You have to manually select the folder that contains your data
% Make sure to select the right folder
folderPath = uigetdir('C:\Users\antonin.gauchy\Documents\THESIS\EEMs\Test_matlab\MARNE_0204','');
%load the emcor and excor data
emcor_data = readmatrix('C:\Users\antonin.gauchy\Documents\THESIS\EEMs\Test_matlab\Marne_0204\Res_RU\Emcor.csv');
excor_data = readmatrix('C:\Users\antonin.gauchy\Documents\THESIS\EEMs\Test_matlab\Marne_0204\Res_RU\Excor.csv');
emcor_values = emcor_data(1 : 150, 1)';
excor_values = excor_data(1 : 72, 1)';
% List every CSV file founded in the specified folder
fileList = dir(fullfile(folderPath, '*.csv'));
% Make sure that the code found the CSV
if isempty(fileList)
error('Aucun fichier CSV trouvé dans le dossier spécifié.');
end
% Counter for the number of CSV files processed
counter = 0;
% Loop to process each CSV file
for i = 1:min(length(fileList), 6)
% Import CSV file as a matrix
filePath = fullfile(folderPath, fileList(i).name);
data = readmatrix(filePath);
% Create X and Y coordinate grids corresponding to the size of data
[X,Y] = meshgrid(emcor_values, excor_values);
% Create a contourf plot
figure;
contourf(X,Y,data);
% Add a color bar
colorbar;
colormap(redwhiteblue(-1, 1));
h = colorbar;
% Specify the scale of the color bar
clim([0 1]);
% Add a name to the color bar
ylabel(h, 'Intensity (RU)');
% Add a title for the spectrum and labels for the axis
title(['Spectre de fluorescence 3D ', fileList(i).name]);
xlabel('λEx. (nm)');
ylabel('λEm. (nm)');
% Increment counter
counter = counter + 1;
end
% Loop through all CSV files found for plotting differences
for i = 1:6
% Import pairs of CSV files
filePath1 = fullfile(folderPath, fileList(i).name);
data1 = readmatrix(filePath1);
filePath2 = fullfile(folderPath, fileList(i+1).name);
data2 = readmatrix(filePath2);
% Calculate the difference
diff_data = data1 - data2;
% Create a contourf plot with the difference
figure;
colormap(redwhiteblue(-1, 1));
contourf(diff_data);
% Add a color bar and name it
h = colorbar;
ylabel(h, 'Intensity (RU)');
% Specify the scale of the color bar
clim([-1 1]);
% Add a title to the spectrum and axis labels
title(['Différence entre les Spectres de fluorescence 3D ', fileList(i).name, ' et ', fileList(i+1).name]);
xlabel('λEx (nm)');
ylabel('λEm (nm)');
end
end
I'm sorry but I'm a beginner to matlab and I've mostly used what I found online and didn't really create it myself so I 'm very counfused.

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!