Plotting subplots in a for loop
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello! I am currently trying to work on something that I believe is very simple, but can't seem to get it. I have 4 different .mat files that have 4 different FRF's that are stored as strucutres. I am able to pull each y_value from each structure and plot the abs for each FRF. I would LOVE for the script to pull each y_value from each .mat file and then plot the 4 different abs of the FRF on one figure (in a clean way - where the peak's for each FRF is clearly defined), with a different color for each FRF. When I tried it this way, the figure was a mess, and decided to have one figure with 4 subplots for each FRF, however I am having an issue coding that part.
Here is what I have so far and attached are the .mat files:
clear all
clc
%% Rubber Material at different nodes
data1 = importdata ('acc_1_rubber.mat');
data2 = importdata ('acc_2_rubber.mat');
data3 = importdata ('acc_3_rubber.mat');
data4 = importdata ('acc_4_rubber.mat');
data_all = [data1; data2; data3;data4];
for i = 1:length(data_all)
FRF{i} = data_all(i).y_values.values;
figure(1)
subplot(i,1,i)
plot(abs(FRF{i}(i,:)));
end
댓글 수: 0
채택된 답변
VBBV
2021년 1월 4일
편집: VBBV
2021년 1월 4일
clear all
clc
%% Rubber Material at different nodes
data1 = importdata ('acc_1_rubber.mat');
data2 = importdata ('acc_2_rubber.mat');
data3 = importdata ('acc_3_rubber.mat');
data4 = importdata ('acc_4_rubber.mat');
data_all = [data1; data2; data3;data4];
K = length(data1.y_values.values)
for i = 1:length(data_all)
FRF{i} = data_all(i).y_values.values;
figure(1)
subplot(length(data_all),1,i)
plot(abs(FRF{i}(1:K,:)));
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!