2D plot using data from different text files

1 次查看(过去 30 天)
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 个评论
Mathieu NOE
Mathieu NOE 2024-1-25
hello
do you have started a code ? can you share it with the data files?
Dyuman Joshi
Dyuman Joshi 2024-1-25
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.

请先登录,再进行评论。

回答(1 个)

George Abrahams
George Abrahams 2024-1-25
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".

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by