How do I loop plots part2

3 vues (au cours des 30 derniers jours)
Mackenzie Maher
Mackenzie Maher le 15 Oct 2021
Modifié(e) : Image Analyst le 15 Oct 2021
Hi all,
Im very new to Matlab and im trying to create a looop that plots the following
scatter(MCR_full.MIB035.Reaches.R32.kin(:,1),MCR_full.MIB035.Reaches.R32.kin(:,3))
scatter(MCR_full.MIB035.Reaches.R41.kin(:,1),MCR_full.MIB035.Reaches.R41.kin(:,3))
scatter(MCR_full.MIB035.Reaches.R88.kin(:,1),MCR_full.MIB035.Reaches.R88.kin(:,3))
scatter(MCR_full.MIB035.Reaches.R90.kin(:,1),MCR_full.MIB035.Reaches.R90.kin(:,3))
scatter(MCR_full.MIB035.Reaches.R100.kin(:,1),MCR_full.MIB035.Reaches.R100.kin(:,3))
all on one plot
Any help with this would be fantastic thanks so much

Réponse acceptée

Image Analyst
Image Analyst le 15 Oct 2021
Modifié(e) : Image Analyst le 15 Oct 2021
How is this any different than what I showed you here:
% Create sample data
MCR_full.MIB035.Reaches.R32.kin = rand(100, 3)
MCR_full.MIB035.Reaches.R33.kin = rand(100, 3)
MCR_full.MIB035.Reaches.R34.kin = rand(100, 3)
MCR_full.MIB035.Reaches.R41.kin = rand(100, 3)
MCR_full.MIB035.Reaches.R100.kin = rand(100, 3)
% Get all the fieldnames.
fieldNames = fieldnames(MCR_full.MIB035.Reaches)
% Get data from each field and plot it.
for k = 1 : numel(fieldNames)
thisFieldName = fieldNames{k};
fprintf('Plotting %s.\n', thisFieldName);
thisArray = MCR_full.MIB035.Reaches.(thisFieldName).kin;
x = thisArray(:, 1);
y = thisArray(:, 3);
% Unique, random color for each.
thisColor = rand(1, 3);
% Do the scatter plot
scatter(x, y, 30, thisColor, 'filled');
hold on; % Don't let subsequent plots blow away earlier ones.
end
grid on;

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by