2D plot using data from different text files

1 vue (au cours des 30 derniers jours)
Karthika Sankar
Karthika Sankar le 25 Jan 2024
Commenté : Dyuman Joshi le 25 Jan 2024
I have 11 text files with two columns - one is wavelength and other is transmittance. Each file is for a particular angle of incidence. Now I need to plot a 2d plot with color bar depicting variations in transmittance with wavelength along one axis and angle of incidence along another axis. What code should I use ?
  2 commentaires
Mathieu NOE
Mathieu NOE le 25 Jan 2024
hello
do you have started a code ? can you share it with the data files?
Dyuman Joshi
Dyuman Joshi le 25 Jan 2024
Do you have problem importing the files and subsequently the data? In that case, check - https://in.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html
Otherwise, specify what you are having trouble with.

Connectez-vous pour commenter.

Réponses (1)

George Abrahams
George Abrahams le 25 Jan 2024
Something along these lines? (Pun intended)
fileNames = [ "a.txt", "b.txt", "c.txt", "d.txt", "e.txt" ];
angleOfIncidence = [ 0, 20, 40, 60, 80 ]; % in the same order as fileNames.
n = numel( fileNames );
ax = axes( "NextPlot", "add", "ColorOrder", turbo( n ), "Box", "on" );
for iFileName = 1 : n
% Read the text files.
fileData = readmatrix( fileNames(iFileName) );
% Plot the wavelength-transmittance line.
plot( ax, fileData(:,1), fileData(:,2), "LineWidth", 2 )
end
xlabel( ax, "Wavelength [nm]" )
ylabel( ax, "Transmittance [%]" )
lgd = legend( ax, string( angleOfIncidence ) + "°", ...
"Location", "eastoutside" );
title( lgd, "Angle of Incidence" )
From a quick Google, this seems to be the typical format for graphs of this type.
I don't think this is what you requested, but I can't figure out exactly what you mean by "a color bar depicting variations in transmittance with wavelength along one axis and angle of incidence along another axis".

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by