why do i got this error?
3 次查看(过去 30 天)
显示 更早的评论
Unable to perform assignment because the size of the left side is 153-by-1 and the size of the right side is 51-by-1-by-3.
d =calc(Vp,Vs,Rh,wavelet,ang);
when i want to perfurm for loop i hane got this error knowing that the calc is function give output 3darray
15 个评论
Image Analyst
2021-11-25
OK, I've downloaded them all, so edit your post and delete one attachment like it says, and upload the mat file.
回答(2 个)
Image Analyst
2021-11-22
You can try
t = calc(Vp,Vs,Rh,wavelet,ang) % t should by 51x1x3.
% Squeeze to get a 51x3
t = squeeze(t); % A 51c3
whos t
d = t(:, 1); % Take column 1 of t and put it into d
0 个评论
Image Analyst
2021-11-25
I don't know exactly what you're doing but look at this:
function [updatemodel, k_gain] = ESMDA_inversion(w, data, d_pred, alfa, Cd)
[nd, ne] = size(d_pred);
% data perturbation
term1 = repmat(data,1,ne);
term2 = sqrt(alfa*Cd);
term3 = randn(nd, ne);
term4 = term2 * term3;
whos data
whos term1
whos term2
whos term3
whos term4
dpert=repmat(data,1,ne) + sqrt(alfa*Cd)*randn(nd, ne);
% mean models
mm = mean(w, 2);
md = mean(d_pred, 2);
% covariance matrices
cmd = 1/(ne-1) * (w - mm) * (d_pred - md)';
cdd = 1/(ne-1) *(d_pred - md) * (d_pred - md)';
% Kalman Gain
k_gain = cmd * inv(cdd + alfa*Cd);
% Updated models
updatemodel = w + k_gain*(dpert - d_pred);
end
If you run that you'll see
Name Size Bytes Class Attributes
data 51x3 612 single
Name Size Bytes Class Attributes
term1 51x1500 306000 single
Name Size Bytes Class Attributes
term2 153x153 93636 single
Name Size Bytes Class Attributes
term3 153x500 612000 double
Name Size Bytes Class Attributes
term4 153x500 306000 single
and you're trying to add term4 to term1. But you cannot add a 153 row matrix to a 51 row matrix. To add matrices they must have the same number of rows and columns. Examine the logic of your program and try to figure out what you really want to do.
3 个评论
Image Analyst
2021-11-25
OK but my answer stands. I put a breakpoint on the line where it tried to add two differently shaped matrices. You need to fix that.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!