describing code (for loop)

2 次查看(过去 30 天)
ahmad ramadan
ahmad ramadan 2018-10-18
评论: madhan ravi 2018-10-18
can you describe the code below
function [Y] = mu_law_expander(Xq,u)
for n = 1:numel(Xq)
disp(n);
Y(n) = ((-1 + (1+u)^abs(Xq(n))) / u) * sign(Xq(n));
end
%%

回答(1 个)

madhan ravi
madhan ravi 2018-10-18
编辑:madhan ravi 2018-10-18
Xq is a vector , u is a scalar
the loop runs from 1 to the number of elements of Xq
number of iteration is displayed which is n here
and then the value is calculated according to the given formula
abs() considers Xq value as positive even if the value is negative and sign() returns 1 if the value is greater than zero and zero otherwise are matlab's inbuilt function
that's it
  1 个评论
madhan ravi
madhan ravi 2018-10-18
if something is not clear let know else accept the answer

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by