How do I loop plots part2

3 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2021-10-15
编辑:Image Analyst 2021-10-15
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;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by