plot graph from cell array
古いコメントを表示
I have loaded 15 excel files into matlab and saved them all as a 15x1 cell.
My aim is to create 15 graphs, showing the contents of each row of the cell array against tim in a subplot.
I have made a for loop, which I ant to loop thorugh each doubl ein the cell array and plot against time. This does make 15 plots but I think it is plotting the same data 15 times. Would anybody be able to help?
%% load all the excel files in, using the same method as csv
files = dir('*.xlsx'); %dir lists the files in a folder. In the specified folder, recognise all the .xlsx files
num_files = length(files); %specify how many files have been found and call it num_files
grainsleft = cell(length(files), 1); %create a cell array the same length as the number of files in one column
%for all the files found in the specified folder, read the tables of data and fill the empty cell array 'results' with the data in each .xlsx file
for a = 1:num_files
grainsleft{a} = readtable(files(a).name);
end
%% time steps
%number of xlsx files = number of time steps the model is run for (seconds)
totalruntime = 3001
time = 1:totalruntime;
%% mass efflux vs. time
%subplot all the mass efflux plots
for b = 1:length(grainsleft)
g{b} = grainsleft{b}(:,1);
g_array{b} = table2array(g{b});
gl{b}= g_array{b}
end
for c = 1:length(gl)
subplot(4,4,c)
bar(time,gl{c}(:,1), 0.01, 'EdgeColor', 'r')
hold on
end
2 件のコメント
Adam Danz
2021 年 1 月 11 日
At quick glance it looks OK but I don't put much weigh on human-read code. If you save grainsleft to a mat file and attach it, we can run the code.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


