关于给定公式的回归分析出错。

我写了这样了一个回归分析,但是总是提示出错,不知错在哪里,请高手帮我看看啊
t=[1 2 3 4 5 6 7 8 9 10]
y=[1.4294 1.2496 1.2010 1.1972 1.2097 1.2290 1.2521 1.2783 1.3075 1.3398]
fun1=inline('exp((t*v - b*t).^a)./8 + (7*exp((-b*t).^a))./8+1','beta','t') ;
v=beta(1);
b=beta(2);
a=beta(3);
beta=nlinfit(t,y,fun1,[1.2 1.1 1])
运行完了显示??? Undefined function or method 'rr' for input arguments of type 'double'. 求大神,不胜感激

 Respuesta aceptada

mepev
mepev el 21 de Nov. de 2022

0 votos

这个错误主要是你定义变量时候没定义好,我帮你改了改,如下:
%% 清空环境变量
close all; clear; clc;
%% 主程序
t=[1 2 3 4 5 6 7 8 9 10];
y=[1.4294 1.2496 1.2010 1.1972 1.2097 1.2290 1.2521 1.2783 1.3075 1.3398];
fun1=inline('exp((t*beta(1) - beta(2)*t).^beta(3))./8 + (7*exp((-beta(2)*t).^beta(3)))./8+1','beta','t');
beta=nlinfit(t,y,fun1,[1.2 1.1 1])
y_fit = exp((t*beta(1) - beta(2)*t).^beta(3))./8 + (7*exp((-beta(2)*t).^beta(3)))./8+1;
hold on
plot(t,y,'ro-');
plot(t,y_fit,'g*--');
hold off
legend('原数据','拟合结果')
title('数据拟合')
xlabel('t')
ylabel('y')
结果如图

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 21 de Nov. de 2022

Respondida:

el 21 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!