fitting a graph and coloring each fit
Afficher commentaires plus anciens

i wrote the following code % Color settings
r_220_w = [10.78, 20.33, 24, 27.7, 35.86, 32.5, 33.2, 30.75, 36.83, 33.44, 32.8, 45.66, 33.04, 39, 50.45, 34.78, 4.96];
r_220_aw = [0.01, 0.02, 0.02, 0.03, 0.02, 0.02, 0.02, 0.01, 0.02, 0.02, 0.02, 0.02, 0.02, 0.1, 0.05, 0.03, 0.03];
r_220_v = [1.02, 1.42, 1.82, 2.62, 5.92, 7, 8.24, 4.48, 4.64, 8.44, 7.5, 1.2, 8.01, 2.91, 0.87, 7.72, 0.973];
r_220_av = [0.01, 0.01, 0.02, 0.01, 0.01, 0.05, 0.01, 0.01, 0.05, 0.05, 0.1, 0.05, 0.05, 0.01, 0.01, 0.1, 0.001];
r_10_w = [33.05, 33.14, 33.1, 33.3, 31.1, 32.7, 35.9, 37.2, 22.9, 20.3, 33.7, 40.4, 27.07, 51.1, 34.45, 10.7, 4.97];
r_10_aw = [0.1, 0.05, 0.1, 0.1, 0.1, 0.1, 0.1, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.1, 0.01, 0.1, 0.02];
r_10_v = [12.9, 13.5, 13.2, 13.8, 5.5, 10.8, 6.9, 4.57, 1.76, 1.52, 14.2, 2.4, 2.56, 0.77, 11.8, 1.02, 0.973];
r_10_av = [0.2, 0.2, 0.1, 0.1, 0.3, 0.1, 0.2, 0.02, 0.01, 0.01, 0.1, 0.1, 0.1, 0.01, 0.1, 0.1, 0.01];
r_2000_w = [52.67, 46.18, 39.33, 35.12, 34.12, 33.55, 10.91, 15.81, 20.77, 25.39, 29.21, 31.21, 42.96, 37.35, 4.98];
r_2000_v = [0.608, 0.888, 1.44, 1.8, 1.84, 1.88, 1.02, 1.13, 1.31, 1.56, 1.8, 1.88, 1.13, 1.62, 0.973];
r_2000_aw = [0.01, 0.02, 0.03, 0.01, 0.01, 0.03, 0.01, 0.01, 0.03, 0.02, 0.01, 0.02, 0.03, 0.02, 0.02];
r_2000_av = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.01, 0.01, 0.01, 0.02, 0.01, 0.02, 0.01, 0.05];
r_1000_w = [34.71, 33.4, 32.5, 33, 35.56, 47.05, 37.6, 30.01, 10.53, 15.84, 20.75, 25, 31.97, 40.34, 44.03, 52.78, 4.96];
r_1000_v = [3.2, 3.35, 3.25, 3.3, 3.05, 0.976, 2.5, 2.74, 1.02, 1.18, 1.42, 1.82, 3.16, 1.86, 1.28, 0.664, 0.973];
r_1000_aw = [0.1, 0.02, 0, 0.1, 0.03, 0.02, 0.05, 0.03, 0.02, 0.01, 0.05, 0.03, 0.03, 0.02, 0.02, 0.02, 0.03];
r_1000_av = [0.01, 0.1, 0.01, 0.01, 0.03, 0.001, 0.01, 0.02, 0.01, 0.01, 0.02, 0.01, 0.01, 0.02, 0.01, 0.1, 0.001];
data = {
r_1000_w, r_1000_v, r_1000_av, r_1000_av, r_1000_aw, r_1000_aw;
r_2000_w, r_2000_v, r_2000_av, r_2000_av, r_2000_aw, r_2000_aw;
r_220_w, r_220_v, r_220_av, r_220_av, r_220_aw, r_220_aw;
r_10_w, r_10_v, r_10_av, r_10_av, r_10_aw, r_10_aw
};
color = [1 0.38 0.53]; % Specify your desired color
lineWidth = 1.5; % Specify the line width
% % Loop through each dataset and plot error bars
for i = 1:size(data, 1)
errorbar(data{i, 1}, data{i, 2}, data{i, 3}, data{i, 4}, data{i, 5}, data{i, 6}, ...
'.', 'Color', color, 'LineWidth', lineWidth);
hold on;
end
it is really hard to see since the same color is being used for all of them i thought it would switch in the range given with each graph , and also if i want to do a fit using cftool and then import it and add it to a sepreat graph without the error bars so that each fit has a color how can i possibly do that
3 commentaires
Ganesh
le 22 Juin 2024
You could simply remove the color setting and MATLAB would automatically choose different colours for each of the plots:
errorbar(data{i, 1}, data{i, 2}, data{i, 3}, data{i, 4}, data{i, 5}, data{i, 6}, ...
'.', 'LineWidth', lineWidth);
dareen
le 22 Juin 2024
dareen
le 22 Juin 2024
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Orange dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
