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

1 次查看(过去 30 天)
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.

回答(1 个)

John D'Errico
John D'Errico 2021-10-16
编辑:John D'Errico 2021-10-16
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.

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by