How to plot a fitted curve?

조회 수: 8 (최근 30일)
afrya
afrya 2013년 12월 18일
댓글: Wayne King 2013년 12월 18일
Hello,
I would like to fit a curve with the following function: y=a-b*c^x
I used this expression with matlab: ft=fittype('a-b*c^x') However,I have a problem when I plot the fit.
I get this message:
Error using plot Conversion to double from fittype is not possible.
Error in project8 (line 149) plot(ft,y2,Av)

답변 (1개)

Wayne King
Wayne King 2013년 12월 18일
편집: Wayne King 2013년 12월 18일
Did you actually call fit() after you definted your fit type?
a = 2;
b = 3;
x = (0:100)';
y = 2-3*x;
ft=fittype('a+b*x')
f = fit(x,y,ft);
plot(f)
hold on;
plot(x,y)
  댓글 수: 2
afrya
afrya 2013년 12월 18일
no, I didn't call fit after I defined fit type. Perhaphs, this is the reason of the error message from matlab. My function isn't 'a+b*x' but 'a+b*c^x'
Wayne King
Wayne King 2013년 12월 18일
I was just showing you an example, not trying to do exactly what you are trying to do. I think I answered your question then, the problem is you have to use fit() to obtain the actual fit.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by