How do I loop plots part2

3 ビュー (過去 30 日間)
Mackenzie Maher
Mackenzie Maher 2021 年 10 月 15 日
編集済み: Image Analyst 2021 年 10 月 15 日
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 Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by