How do I loop plots part2

3 visualizaciones (últimos 30 días)
Mackenzie Maher
Mackenzie Maher el 15 de Oct. de 2021
Editada: Image Analyst el 15 de Oct. de 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

Respuesta aceptada

Image Analyst
Image Analyst el 15 de Oct. de 2021
Editada: Image Analyst el 15 de Oct. de 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;

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by