How to set a value according to a range without using a for loop?
3 次查看(过去 30 天)
显示 更早的评论
Hello everybody.
I need to obtain r̂ values using next function:
where
I created an array gu to store all gu values from 0 to 128 using the function g.
The r values (to obtain r̂) are stored into an array called dct_values.
It is possible to compute r̂ values without using for loop (for example, when gu ⩽ r < gu+1) ?
Thanks for your help.
u = [0:128];
gu = g(u);
2 个评论
Walter Roberson
2020-2-4
u = 0:128;
gu = u.^2/90 + u/3;
Now consider discretize() of r with bins [-fliplr(gu), gu] . Then the bin-number can be used to index the replacement matrix [-128, -fliplr(u)-1, u, 127]
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!