can anyone help me to find the solution of the statement "how to get the values only in the places where A has"

1 次查看(过去 30 天)
A=[0 0.6318 0 4.0000 0.1662 0 0 0 0.5583 0;
0 0.1265 0 0.2120 5.0000 0 0 0 0.7425 0;
0 2.0000 0 0.7032 0.5578 0 0 0 2.0000 0]
B=size(A)
C=rand(B)
If i run the code it executes but for C it gives values for all the places. But how to get the values only in the places where A has.

采纳的回答

Walter Roberson
Walter Roberson 2018-1-15
C = rand(size(A)) .* (A ~= 0);
  2 个评论
Prabha Kumaresan
Prabha Kumaresan 2018-1-24
The above command works fine. In the command since rand is being used C takes random number of values. could you please tell me how to have the random value under the condition "such that the minimum should be 0.001 and maximum should be 0.300 " and adding up of all the values should be equal to 0.35.could you please help me how to have the minimum,maximum and add onto the command line.

请先登录,再进行评论。

更多回答(1 个)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by