Create an array in workspace from multiple files
显示 更早的评论
,filenames={'kx 10.txt','kx 20.txt','kx 30.txt'}
for i=1:numel(filenames)
load(filenames{i});
%print(filenames{i});
t_data(:,i) = lum.y0
end
Each file contains two columns of data, the first column is the range of frequency (same for every file) and the second column is the corresponding data (transmission). How can I create a block in the workspace to compile all the transmission data? (lum.x0 and lum.y0 is from the previous code. lum.y0 compiles all transmission data)
I wanted to make a colormap to represent different transmission data over the same range of frequency for all kx values (from file 0 to file 500). How can I proceed from here? Thank you.
%making the plot
angle = linspace(0,0.5,51);
wav_leng = lum.x0.';
figure;
imagesc(angle,wav_leng,t_data); colormap turbo; axis xy;
xlabel('kx')
ylabel('Freqency (THz)')

5 个评论
Walter Roberson
2022-5-9
Why do you bother to load(), since you ignore what was loaded?
Chalisa Mawla
2022-5-9
KSSV
2022-5-9
Your question is not quiet clear. You have two data points from the text files and third one you are defining on your own. How to link the third one with the existing data?
Chalisa Mawla
2022-5-9
回答(1 个)
unzip("kx values.zip");
filenames = dir('*.txt');
filenames = sort({filenames.name}');
nfiles = length(filenames);
nfiles = 36; % other files have different rows of data; check it out
kx = zeros(nfiles, 1);
for i=1:nfiles
x = readtable(filenames{i});
np = size(x, 1);
var = strrep(filenames{i}, " ", "");
var = strrep(var, ".txt", "");
kx(i) = sscanf(var, 'kx%d');
x.Properties.VariableNames = ["freq", var];
if i == 1
y = x;
else
y = [y x(:, end)];
end
end
head(y)
imagesc(kx, y.freq, y{:, 2:end});
colorbar
类别
在 帮助中心 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

