필터 지우기
필터 지우기

Strange function fit to data points- sorting by first column vals?

조회 수: 1 (최근 30일)
Em
Em 2022년 2월 27일
댓글: Voss 2022년 2월 27일
Hi,
does anyone have any idea why my function has such a strange shape? In the modelling app I'm not getting this.
I think I need to sort the T values keeping the rows together maybe but is there a way to keep columns together and sort by the first column vals?
conductivity4=abs(set4(:,2));
scatter(set4(:,1),conductivity4)
T4=set4(:,1);
hold on
y=(1.236*10^(-12))*exp(0.01189.*T4)
plot(T4,y)
ylim([1 2.2]*10^(-11))
xlim([180 240])
Thanks!

채택된 답변

Voss
Voss 2022년 2월 27일
편집: Voss 2022년 2월 27일
I think it is the points not being in monotonic order in T4, and sorting them first will fix it, like you say.
% T4 values to use, in order:
T4_order = 180:240;
% create a random permutation of those values:
T4 = T4_order(randperm(numel(T4_order)));
% calculate the corresponding y values:
y=(1.236*10^(-12))*exp(0.01189.*T4);
% plot (should have the same problem as your plot):
figure();
plot(T4,y,'r');
% sort the T4:
T4 = sort(T4);
% calculate the corresponding y values:
y=(1.236*10^(-12))*exp(0.01189.*T4);
% plot (should be good):
figure();
plot(T4,y,'r');
  댓글 수: 3

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by