Matlab计算中的不需要的指数输出

时间:2015-02-01 09:35:30

标签: matlab

我正在使用在运行时输入的向量来解决多元回归问题。一些输出变量默认为指数格式,而使用手动校准检查显示它们是错误的。我低估了它;昨天花了一整天来调试和修复它没有成功因此我分享它。我已经对下面的错误输出发表了评论。提前谢谢。

x1 = input('Enter x1 data:');
x2 = input('Enter x2 data:');
y = input('Enter y data:');
a = mean(x1);
b= mean(x2);
c = mean(y);
mean_of_x1 = a
mean_of_x2 = b
mean_of_y = c
L1= (y-c).^2;
L2= (x1-a).*(x2-b);
L3=(x1-a).^2;
L4= (x2-b).^2;
L5= (x2-b).^2;
L6=  (x1-a).*(y-c);
L7= (x2-b).*(y-c);
table =[y; x1; x2; y-c; (y-c).^2; x1-a; x2-b;(x1-a).*(x2-b);(x1-a).^2;(x2-b).^2; (x1-a).*(y-c);(x2-b).*(y-c)];
fprintf('y, x1, x2, y-c, (y-c).^2, x1-a, x2-b, (x1-a).*(x2-b), (x1-a).^2, (x2-b).^2, (x1-a).*(y-c),(x1-a).*(y-c);(x2-b).*(y-c)\n ')
fprintf('%4.2f %8.2f %10.2f %12.2f %14.2f %16.2f %18.2f %20.2f %22.2f %24.2f %26.2f %28.2f\n', table)
 summation_of_x1 = sum(x1)
 summation_of_x2= sum(x2)
summation_of_y = sum(y)
d = y-c;
summation_of_y_minus_C = sum(d)% OUTPUTS EXPO RESULT
summation_of_y_minus_c_square=sum((y-c).^2)
e = x1-a;
summation_of_x1_minus_A=sum(e)
 f = x2-b ;



summation_of_x2_minus_B = sum(f)% OUTPUTS EXPO RESULT

 summation_of_product_x1_minus_A_and_x2_minus_B = sum((x1-a).*(x2-b))
 Summation_x1_minus_A_square= sum((x1-a).^2)
 Summation_x2_minus_B_Square= sum((x2-b).^2)
 summation_product_x1_minus_A_and_y_minus_c = sum((x1-a).*(y-c))
 summation_product_x2_minus_B_and_y_minus_c = sum((x2-b).*(y-c))
x1=[3, 1, 9, 5, 2]; x2=[12, 5, 11, 22, 3]; y=[28,9, 5, 7, 32]%My test data

0 个答案:

没有答案