Effacer les filtres
Effacer les filtres

How can i make this code snippet a function?

1 vue (au cours des 30 derniers jours)
Elias Unk
Elias Unk le 20 Juil 2018
Modifié(e) : Stephen23 le 21 Juil 2018
data1 = load('data1.mat')
data2 = load('data2.mat')
data3 = load('data3.mat')
data4 = load('data4.mat')
full_val = cat(1,data1,data2,data3,data4);
This is where i need the function:
plot(data1.val(1,:));hold on; plot(data2.val(1,:));hold on;plot(data3.val(1,:));hold on;plot(data3.val(1,:));
we can easily how this can become an issue on scale i just want a function to keep drawing the function inside the nx1 matrix full_val across data n

Réponse acceptée

Stephen23
Stephen23 le 20 Juil 2018
Modifié(e) : Stephen23 le 21 Juil 2018
for k = 1:numel(full_val)
plot(full_val(k).val(1,:))
hold on
end
You could also use a loop when load-ing the .mat files.
Note that (assuming compatible sizes) you could plot all of the data at once, without a loop:
tmp = cat(3,full_val.val);
plot(squeeze(tmp(1,:,:))

Plus de réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox 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