Plotting subplots in a for loop

3 次查看(过去 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

采纳的回答

VBBV
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 CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by