Vectorised form and inverse of matrix
1 view (last 30 days)
Show older comments
Hi everyone,
Could someone please tell me if I have any mistakes in my formulas
The original code looks like this:
for i=1:n
ylin(i,1)= m1 + m2*t(i) ; % linear term
y_anu(i,1)= m3*cos( t(i)*w1 + m4) ; % annual term
y_quad(i,1)= m5*t(i)^2 ; % quadratic term
yslope_lin(i,1) = Eslope_x*E_E0(i) + Nslope_y*N_N0(i) ; % lin slope
end
The vectorised form I wrote to reduce time looks like this:
ylin=m1+m2.*t;
y_anu= m3.*cos(t.*w1 + m4); %phase is m4 and the amplitude is m3
y_quad= m5.*t.^2 ;
yslope_lin= Eslope_x.*E_E0 + Nslope_y.*N_N0;
Also, is there a better way to rewrite this formula?
C_obs = diag(err);
inv((G')*inv(C_obs)*G)*(G')*inv(C_obs)*delta_d ;
Thank you very much in advance
0 Comments
Answers (1)
Matt J
on 29 Apr 2023
Edited: Matt J
on 29 Apr 2023
The vectorised form I wrote to reduce time looks like this:
You should be able to see if it's correct by comparing hte output of both.
Also, is there a better way to rewrite this formula?
Yes, instead of,
out = inv((G')*inv(C_obs)*G)*(G')*inv(C_obs)*delta_d ;
use lscov,
out = lscov(G,delta_d, C_obs)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!