嗨我是新的matlab gui我有文本文件,我转换成二进制然后将这些binnary传递给mfsk函数,但它给我以下错误请尽快帮助我,我发布我的完整代码我能做什么请。 .....
Error using .*
Integers can only be combined with integers of the same class, or scalar doubles.
Error in GUI2>menu_mscheme_mfsk_2_Callback (line 217)
d_xover_den =((4*pi./lambda).^2*(1+alpha)*SNR_unc./(2*Gr*Gt).*b*B*noise*NF.*Ton*(1- 1/CG));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in GUI2 (line 43)
gui_mainfcn(gui_State, varargin{:});
我的文字代码是
filename= uigetfile('*.txt','File select text');
txt = fopen(filename);
txtbits = fread(txt, inf, '*ubit1', 'b');
openvar('txtbits');
fclose(txt);
fileID = fopen(filename);
C = textscan(fileID,'%s');
i = C{1}{1};
dec2bin(i);
fclose(fileID);
celldisp(C);
set(handles.text3,'string',filename);
set(handles.text4,'string',txtbits);
handles.binary=txtbits;
guidata(hObject, handles);
我的mfsk代码是
decimal=handles.binary
N=decimal;
charact = {'b-+','b-o','b-v','b-^','b-*'};
j=0;
for N=50:20:150
j=j+1;
b=2;
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*2^b./(b*B);
SNR_unc = 10;
K=24;
N_o_K = 30/24;
alpha = 1.9;
n=6; % path loss component
E_comp = 5; % To CONFORM the value
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);
d_xover_den = ((4*pi./lambda).^2*(1+alpha)*SNR_unc./(2*Gr*Gt).*b*B*noise*NF.*Ton*(1- 1/CG));
d_xover = (d_xover_num./d_xover_den).^(1/n);
% d_xover = abs(d_xover);
axes(handles.abc)
plot(freq,d_xover,charact{j});
hold on
xlabel('Carrier Frequency'), ylabel('Cross-over distance (m)')
grid on
hold on
end
legend ('N=50','N=70','N=90','N=110','N=130')
答案 0 :(得分:0)
您可能需要查看decimal
。使用fread作为txtbits = fread(txt, inf, '*ubit1', 'b')
读取句柄,其精度为*ubit1
。从文档中您可以看到,它读取文本并将数据作为无符号整数返回。然后,这与向量frequency
不兼容,它是double类型。您需要将数据转换为相同的格式。
但是,我将来会建议使用调试器并首先尝试自己调试代码。