Question

hi i am new in matlab gui i have text file which i convert into binary then pass these binnary to mfsk function but it give me following error plese help me as soon as possible i post my full code what i can do please......

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{:});

my text code is

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);

my mfsk code is

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')
Was it helpful?

Solution

You may want to check decimal. The handle are read using fread as txtbits = fread(txt, inf, '*ubit1', 'b'), which have the precision *ubit1. From the documentation you would see that this reads the text and returns the data as unsigned integers. This is then not compitable with the vector frequency, which is of type double. You need to convert the data to the same format.

However, I would in the future recommend to use the debugger and try to debug the code yourself first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top