Is there a way to create a lot of graphs for a 4D matrix without coding for a ton of individual graphs?
Show older comments
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 Comments
Josh
on 8 May 2024
you can certainly script graph creating and automate the process. is that all you're seeking?
Josh
on 8 May 2024
if that's the case, you just need to iterate acreoss those dimensions, probably something like:
for i1=1:size(matrix,2)
for i2=1:size(matrix,3)
currentGraph=opt(:,i1,i2,:);
imagesc(currentGraph);
colorbar;
xlabel('Time');
ylabel('State');
set(gca,'YDir','normal');
axis('square')
-> insert line for saving graph/figure however you want
end
end
Dyuman Joshi
on 8 May 2024
Make a for loop and iterate through the varying values corresponding to your objective to make the plots.
"I want to make a bunch of graphs within a larger "graph""
Kitt
on 8 May 2024
Kitt
on 8 May 2024
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!