How do I loop plots part2

2 Ansichten (letzte 30 Tage)
Mackenzie Maher
Mackenzie Maher am 15 Okt. 2021
Bearbeitet: Image Analyst am 15 Okt. 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

Akzeptierte Antwort

Image Analyst
Image Analyst am 15 Okt. 2021
Bearbeitet: Image Analyst am 15 Okt. 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;

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by