【问题标题】:Why my code is only returning one output? MATLAB为什么我的代码只返回一个输出? MATLAB
【发布时间】:2022-11-13 23:51:24
【问题描述】:

嗨,我正在尝试从 MATLAB 中的以下代码中获得两个返回:

function [Xq, SNq] = cuantificacion(x,xmax,xmin,b)
N = input('Introduce un numero de muestras: ');
L = 2^b;
delta = (xmax-xmin)/L;
if(abs(x)<xmax)
    Xq = (fix((abs(x)/delta)) + 1/2)*delta*sign(x);
else
    Xq = ((L-1)/2)*delta*sign(x);
end
p = 0;
q = 0;
for i = 0:N
    p = p+x^2;
q = q + (Xq - x);
end
Px = 1/N*p;
Pq = 1/N*q;
SNq = 10*log(Px/Pq);
end

但我只得到一个回报,我不明白为什么。

【问题讨论】:

  • 您肯定将其称为[return1, return2] = cuantificacion(x,xmax,xmin,b); 而不是return1 = cuantificacion(x,xmax,xmin,b);,甚至不是cuantificacion(x,xmax,xmin,b);,对吗?您正在获取返回值吗?
  • 哦耶!抱歉我刚开始使用MATLAB,谢谢!

标签: matlab


【解决方案1】:

感谢@Ander Biguri,我只是说错了。我不得不称它为: [返回 1,返回 2] = cuantificacion(x,xmax,xmin,b);

【讨论】:

    猜你喜欢
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-19
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2023-03-05
    相关资源
    最近更新 更多