Effacer les filtres
Effacer les filtres

Plotting subplots in a for loop

2 vues (au cours des 30 derniers jours)
Christina Reid
Christina Reid le 4 Jan 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

Réponse acceptée

VBBV
VBBV le 4 Jan 2021
Modifié(e) : VBBV le 4 Jan 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

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by