I have curve fitting in matlab. My graph were all good when not add scatter in the graph. However, when i add scatter coding, the graph were not remain it origin.

1 view (last 30 days)
First photo: The graph that i want but not add scatter point.
Second photo: The graph when i add scatter coding.
I do not know what the problem here. It is for my final year project. Kindly ask for your help. This is the coding with adding scatter point:
scatter (prev_15AoA,prev_15CL,'o','filled','b');hold on
scatter (curr_15AoA,curr_15CL,'s','filled','b');hold on
scatter (prev_15AoA,prev_20CL,'^','filled','g');hold on
scatter (curr_15AoA,curr_20CL,'d','filled','g');hold on
scatter (prev_15AoA,prev25_CL,'>','filled','r');hold on
scatter (curr_15AoA,curr25_CL,'v','filled','r');hold on
f1 = fit(prev_15AoA,prev_15CL,'poly5')
f2 = fit(curr_15AoA,curr_15CL,'poly6')
plot(f1,'b')
plot(f2,'b--')
hold on
f3 = fit(prev_15AoA,prev_20CL,'poly5')
f4 = fit(curr_15AoA,curr_20CL,'poly6')
plot(f3,'g')
plot(f4,'g--')

Answers (1)

Matt J
Matt J on 20 Jun 2023
Edited: Matt J on 20 Jun 2023
It's hard to compare the two plots, because the x- and y-axes ranges are different in each. I suspect if you made the ranges the same, the plots will look the same.
  1 Comment
Matt J
Matt J on 20 Jun 2023
Edited: Matt J on 20 Jun 2023
That is,
f1 = fit(prev_15AoA,prev_15CL,'poly5')
f2 = fit(curr_15AoA,curr_15CL,'poly6')
f3 = fit(prev_15AoA,prev_20CL,'poly5')
f4 = fit(curr_15AoA,curr_20CL,'poly6')
plot(f1,'b'); hold on
plot(f2,'b--');
plot(f3,'g');
plot(f4,'g--');
scatter (prev_15AoA,prev_15CL,'o','filled','b');
scatter (curr_15AoA,curr_15CL,'s','filled','b');
scatter (prev_15AoA,prev_20CL,'^','filled','g');
scatter (curr_15AoA,curr_20CL,'d','filled','g');
scatter (prev_15AoA,prev25_CL,'>','filled','r');
scatter (curr_15AoA,curr25_CL,'v','filled','r'); hold off
xlim([-0.2,1.2])
ylim([0,20])

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!