How can i write this equation: d = obs + sqrt(alfa*​Cd^0.5)*ra​ndn(nd, ne)

1 view (last 30 days)
Hi everyone
I have a problem with this equation in MATLAB:
d = obs + sqrt(alfa*Cd^0.5)*randn(nd, ne);
% where the diminsion of
obs= 51*71*3
alfa=0.002
Cd=71*71
nd=51
ne=500
I got this message error:
Array dimensions must match for binary array op.
How can I fix it? Or does it seem impossible?
Thank you.

Answers (1)

John D'Errico
John D'Errico on 16 Oct 2021
Edited: John D'Errico on 16 Oct 2021
Do I understand you correctly? obs is an array of size 51x71x3? Or is it a vector of that length? Regardless...
alfa is a scalar.
Cd is a scalar. Or is Cd a array of size 71 bt 71?
randn(nd,ne) produces an array of size ndxne, where nd is 51, and ne is 500.
And that means you want to add an array of size 51x71x3 to an array of size 51x500. I'm sorry, but that makes absolutely no sense at all. What do you expect to have as a result? Even if Cd is an array of size 71 by 71, things still do not match in size.
The error message indicates that these arrays cannot be added to each other, and that makes complete sense.

Categories

Find more on Multidimensional Arrays 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!