How to put multiple contours into a figure as separate subplots?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
I have a set amount of contour plots generated by my code, with each one being saved as a figure. I want to import the contour plots into an individual figure in a way that allows me to index them based on their number value. For example:
 'Impact_Angle_1_1.fig' would be placed in the subplot within the top left corner of the figure. The colorbar and axes titles need to be included.
'Impact_Angle_1_2.fig' would be placed to the right of 'Impact_Angle_1_1.fig'. The colorbar and axes titles also need to be included.
Then, I would start at the next row with 'Impact_Angle_2_1.fig', after ending the previous row with 'Impact_Angle_1_5.fig'.
My current attempt at this was as follows:
keytestnames = {'Impact_Angle_' 'Leg_Torque_' 'Rollover_Metric_' 'KE_Ratio_' 'Impact_Velocity_'};
n = length(keytestnames);
filePattern = fullfile(folder, '*.fig' ); 
theFiles = dir(filePattern); %Creates a structure array that contains all figure files generated from other code file.
for i = 1:n
    %This is to create a keyword to sort the files of a given output so that you can begin sorting by parameter sweep.
    idx = contains({theFiles.name},keytestnames{i})==1; 
    h3 = figure; %Create the figure used to contain each subplot
    for plotId = 1 : n^2 % This value is to create an even square array of subplots
        baseFileNames = {theFiles(idx).name}; %Finding the files that all are under the same test name. 
        h1 = openfig(baseFileNames{plotId},'reuse'); 
        ax = gca;
        aux= get(h1,'Children');
        sub = subplot(n, n, mod(plotId-1, n)+1) ;
        copyobj(ax,sub);
    end
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
			
	제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
