Plotting subplots in a for loop

2 visualizzazioni (ultimi 30 giorni)
Christina Reid
Christina Reid il 4 Gen 2021
Commentato: Christina Reid il 4 Gen 2021
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

Risposta accettata

VBBV
VBBV il 4 Gen 2021
Modificato: VBBV il 4 Gen 2021
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

Più risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by