使用/ Matrix维度时出错必须在matlab gui中达成一致

时间:2014-03-23 21:22:28

标签: matlab matlab-figure matlab-guide matlab-deployment

我一直收到以下错误:

Error using  / 
    Matrix dimensions must agree.
Error in GUI2>menu_mscheme_mpsk_2_Callback (line 579)
    d_xover_den = ((4*pi/lambda).^2*(1+alpha)*SNR_unc./uu)
Error in gui_mainfcn (line 96)
    feval(varargin{:});
Error in GUI2 (line 43)
    gui_mainfcn(gui_State, varargin{:});
Error in
    @(hObject,eventdata)GUI2('menu_mscheme_mpsk_2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uimenu Callback

使用我的代码:

cla(handles.abc, 'reset')
decimal = handles.binary;

N = 110;
charact = {'b-o', 'b-+', 'b-v', 'b-^', 'b-*'}
j = 0;
for N = 50:20:130
    j = j+1;
    b = 2;                              % M-Ary    
    L = decimal;
    freq = linspace(0.3, 7, 20)*1e + 9;
    lambda = 1e+8 ./ freq;
    B = 1e+6;                           % Bandwidth
    n = 5;                              % Path loss
    noise = 4e-21;
    P_ckt=0.02;                         % watt  
    % Ton=0.1;                          % sec
    Ton = L./(b*B);                     % b is No of resolution bits and B is the channel %bandwidth.
    SNR_unc = 10;
    K = 24;                             % information bit before encodings
    N_o_K = 30/24;
    alpha = 1.9;  
    n = 6;                              % path loss component
    E_comp = 5;   
    Gt = 1;
    Gr = 1;
    CG = 10;                            % Code Gain
    NF = 1;                             % noise-factor
    d_xover_num = (P_ckt * Ton * (N/K-1) + L * E_comp * N / K);
    uu = (2 * Gr * Gt) .* b * B * noise * NF .* Ton * (1 - 1/CG)
    d_xover_den = ((4 * pi / lambda).^2 * (1 + alpha) * SNR_unc ./ uu)
    d_xover = (d_xover_num ./ d_xover_den).^(1/n);
    axes(handles.abc)
    plot(freq, d_xover, charact{j})
    xlabel('Carrier Frequency'), ylabel('Cross-over distance (m)')
    grid on
    hold on
end
legend ('N=50', 'N=70', 'N=90', 'N=110', 'N=130')

描述:我选择文本,然后使用dec2bin将其转换为二进制文件。然后我使用handle.binary在mfsk回调函数中访问该二进制文件。二进制值存储在十进制变量中。代码L表示位的传输。

以下是我的问题:是否正确分配二进制值?

1 个答案:

答案 0 :(得分:0)

d_xover_den = ((4*pi/lambda).^2*(1+alpha)*SNR_unc./uu)

应该是

d_xover_den = ((4*pi./lambda).^2*(1+alpha)*SNR_unc./uu)

lambda是一个向量,因此1/lambda无效。

>> freq=linspace(0.3,7,20)*1e+9;
>> lambda=1e+8./freq;
>> 1/lambda
Error using  / 
Matrix dimensions must agree.

您需要改为使用1./lambda