Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
>> A=[1,1,-1;2,1,2;4,1,1]
A=
1 1 -1
2 1 2
4 1 1
>> b=[11;21;29;34]
b=
11
21
29
34
>> x=A^-1*b
Error using *
Inner matrix dimensions must agree.
>> A=[1,1,-1;2,1,2;3,13;4,1,1]
Dimensions of matrices being concatenated are not consistent.
>> A=[1,1,-1;2,1,2;3,1,3;4,1,1]
A=
1 1 -1
2 1 2
3 1 3
4 1 1
>> x=A^-1*b
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
>> x=A^-1*b
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
>> x=pinv(A)*b
x=
7.0000
5.0000
1.0000
ans =
2.0409e-14
>> randn('seed',0)
>> n=100
n=
100
>> [v,w]=meshgrid(1:10,1:10);
>> v=v(:); w=w(:); %point loads (KN)
>> M=70+4*v+7*w+10*randn(n,1); %moment at the support (KNm)
>> X=[ones(n,1),v,w];
>> y=M;
>> b=(X'*X)^-1*X'*y
b=
71.2280
3.9584
6.9506
>> e=X*b-y;
>> r2=1-sum(e.^2)/sum((y-mean(y)).^2)
r2 =
0.8543
>>