2D plot using data from different text files

1 Ansicht (letzte 30 Tage)
Karthika Sankar
Karthika Sankar am 25 Jan. 2024
Kommentiert: Dyuman Joshi am 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 Kommentare
Mathieu NOE
Mathieu NOE am 25 Jan. 2024
hello
do you have started a code ? can you share it with the data files?
Dyuman Joshi
Dyuman Joshi am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

George Abrahams
George Abrahams am 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