Effacer les filtres
Effacer les filtres

good afternoon everyone can anyone answer me this question ? i have an error in the matlab code

2 vues (au cours des 30 derniers jours)
here are some of the programs that I'm working on
sou_y = [5 10];
rec_y = [5 25 40];
d = [0.1000 0.0977 0.0908
0.1000 0.0977 0.0908];
pan_ray_total= [ 100.0000 101.9084 105.9481
100.1249 101.1187 104.4031];
t_obs = d;
vsem=zeros(length(sou_y),length(rec_y));
for i= 1 :length(sou_y)
for j= 1:length(rec_y)
vsem(i,j) = pan_ray_total(i,j)/t_obs(i,j);
end
end
v0_linier = sum (sum (vsem )) ./ n_ray ;
t_cal_linier = pan_ray_total ./ v0_linier;
dt_linier = t_obs - t_cal_linier;
for l = 1 :length(sou_y)
dt((length(rec_y)*(1-1 ))+1 :length(rec_y)* 1,1 ) =dt_linier(1,:);
end
G = [ 100.0000 0 0 ; 76.4853 25.4951 0; 45.4063 30.2709 0; 100.1249 0 0; 67.4125 33.7062 0; 34.8010 34.8010 34.8010];
G_linier = G ;
misfit = dt.^2;
We = (misfit).^-1;
m_linier = (inv(G_linier'*diag(We)*G_linier))*G_linier'*diag(We)*dt;
dv_linier = zeros(length(m_linier),l);
v_linier = zeros(length(m_linier),1);
for i = 1 :length(m_linier)
dv_linier (i) = (-1*m_linier(i)*v0_linier^2)/(1 + m_linier(i) * v0_linier);
v_linier(i) = v0_linier + dv_linier(i);
end
and i have problem like this
Error using *
Inner matrix dimensions must agree.
Error in te (line 21)
m_linier = (inv(G_linier'*diag(We)*G_linier))*G_linier'*diag(We)*dt;
how can i fix this?

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Nov 2019
I think you need
m_linier = (G_linier*diag(We)*G_linier')\G_linier*diag(We)*dt
  4 commentaires
No Freed
No Freed le 24 Nov 2019
the formula that was given by walter is about resolved my program however i still found the error at matrix iteration like this
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
5.516471e-18.
Thank you
Walter Roberson
Walter Roberson le 24 Nov 2019
When you construct matrices based on 6 x 3 * 3 x 3 * 3 * 6, then the resulting matrix has rank no more than 3. It cannot possibly have an inverse.
You can proceed using pseudo-inverses, but it is not obvious that the result will have any meaning.
Question for you:
for l = 1 :length(sou_y)
So l is a loop control variable. After the loop, it will be left at the last value it was set to, so l = length(sou_y) is true after the for loop.
dv_linier = zeros(length(m_linier),l);
And there you set dv_linier to have l columns -- that is, to have length(sou_y) columns.
dv_linier (i) = (-1*m_linier(i)*v0_linier^2)/(1 + m_linier(i) * v0_linier);
but your syntax only assigns to dv_linier as if it is a vector. Unless you are doing linear indexing/
There are some valid cases to use linear indexing, but it is not obvious that this is any of those cases. My experiments suggest that it is not a place to use linear indexing to address multiple columns. I would suggest to you that perhaps when you define dv_linier that the number of columns should be 1 (the digit one) rather than l (lower-case L that got more or less accidentally left as length(sou_y))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by