Is there a way to create a lot of graphs for a 4D matrix without coding for a ton of individual graphs?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 4D matrix that I'm trying to create graphs for. There are 4 dimensions, a physical state, two informational states, and time.
I want to make a bunch of graphs within a larger "graph" Basically info state 1 on the y axis and info state 2 on the x axis, but then within that, there are a bunch of graphs with physical state on the y axis and time on the x axis.
Here's an example of one graph:
fivexfive(:,:)=opt(:,5,5,:);
imagesc(fivexfive);
colorbar;
xlabel('Time');
ylabel('State');
set(gca,'YDir','normal');
axis('square')
the second two dimensions range from 1-15 each. So that'd be..... a lot of graphs.
Is there any way to try and make at least a few of them without brute forcing a ton of graphs? If that's not possible that's fine, figured I'd try asking!
5 件のコメント
採用された回答
David Goodmanson
2024 年 5 月 8 日
編集済み: David Goodmanson
2024 年 9 月 1 日
Hi Kitt,
Here is one approach. In the example you are using imagsc plots instead of e.g. 1d plots of some state quantity vs. time, so imagesc is used here. This code thinks about it for a few seconds and then makes 15 figures of 15 miniplots each, one of which is below.
A = rand(100,15,15,100); % assuming the order is state,info1,info2,time
B = permute(A,[4 1 2 3]); % put into an easier order, less potential problems for Matlab
for info1 = 1:15
figure(info1)
sgtitle(['inf01 = ' num2str(info1)])
info2 = 1;
subplot(4,4,info2)
imagesc(B(:,:,info1,info2))
title(['info2: ' num2str(info2)])
for info2 = 2:15
subplot(4,4,info2)
imagesc(B(:,:,info1,info2))
title(num2str(info2))
end
end
2 件のコメント
David Goodmanson
2024 年 5 月 9 日
you're quite welcome. Matlab does have some useful plotting options.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!