Borrar filtros
Borrar filtros

2D plot using data from different text files

4 visualizaciones (últimos 30 días)
Karthika Sankar
Karthika Sankar el 25 de En. de 2024
Comentada: Dyuman Joshi el 25 de En. de 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 comentarios
Mathieu NOE
Mathieu NOE el 25 de En. de 2024
hello
do you have started a code ? can you share it with the data files?
Dyuman Joshi
Dyuman Joshi el 25 de En. de 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.

Iniciar sesión para comentar.

Respuestas (1)

George Abrahams
George Abrahams el 25 de En. de 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".

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by