why do i got this error?
Show older comments
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 Comments
KSSV
on 22 Nov 2021
You are trying to save wrong number of elements then the array is initialized for.
Show us the full code.
RADWAN A F ZEYADI
on 22 Nov 2021
Edited: Image Analyst
on 22 Nov 2021
Image Analyst
on 22 Nov 2021
Give us the function line (or the whole function) where you define calc(). Are you sure it wants 5 inputs and not 1 to 4?
And what does this say
which -all calc
RADWAN A F ZEYADI
on 22 Nov 2021
Image Analyst
on 22 Nov 2021
Why are you overwriting Vp, Vs, and Rho. each time? You're not indexing them to save the separate values so at the end of the loop the're all same scalar value, so you might as well have done the loop only once.
Attach Shmean and swmean in a .mat file so we can run your code.
RADWAN A F ZEYADI
on 23 Nov 2021
Image Analyst
on 23 Nov 2021
I find it hard to believe all your scripts zip up to over 5 MB in size (the attachmente limit). Go ahead and attach them if you want more help. By the way, did you try my suggestion in my Answer below? Or did you even see it (scroll down)?
RADWAN A F ZEYADI
on 23 Nov 2021
Image Analyst
on 23 Nov 2021
Edited: Image Analyst
on 23 Nov 2021
@RADWAN A F ZEYADI, I assume you have it figure out now since nothing is attached.
Image Analyst
on 25 Nov 2021
Which m-file is the main program? Do any of the m-files require anything from the wavelet or symbolic toolbox? If so I won't be able to run it.
RADWAN A F ZEYADI
on 25 Nov 2021
Edited: RADWAN A F ZEYADI
on 25 Nov 2021
Image Analyst
on 25 Nov 2021
Edited: Image Analyst
on 25 Nov 2021
>> united777
Error using load
Unable to find file or directory 'model_petro'.
Error in united777 (line 7)
load model_petro
Please attach any files needed at runtime, such as "model_petro.mat".
Also I searched for the line of code you first mentioned and "calc(Vp" does not appear in any of your files. Where is it?
RADWAN A F ZEYADI
on 25 Nov 2021
Image Analyst
on 25 Nov 2021
OK, I've downloaded them all, so edit your post and delete one attachment like it says, and upload the mat file.
RADWAN A F ZEYADI
on 25 Nov 2021
Answers (2)
Image Analyst
on 22 Nov 2021
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
Image Analyst
on 25 Nov 2021
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 Comments
RADWAN A F ZEYADI
on 25 Nov 2021
RADWAN A F ZEYADI
on 25 Nov 2021
Image Analyst
on 25 Nov 2021
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.
Categories
Find more on Denoising and Compression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!