I think the error is in the filename please solve it quickly

1 view (last 30 days)
% File: line_coding.m % Description: Illustration of line coding schemes % EE 160. Fall 2006. San Jose State University. % Modified Spring 2014 and 2015 for EE161. Modified in Spring 2023 which linecodingdemo -all clear A = 1; % Pulse amplitude T = 1; % Bit duration N = 10; % Number of bits seed = input('Enter your student ID: 015084355'); rand('state',seed) bit = round(rand(1,N)); % Bit sequence polar = [ -A +A ]; % Polar mapping M = 32; % Oversampling ratio (must be even) T_bits = T*length(bit); % Duration of bit stream t = 1/M:1/M:T_bits ; % Time scale bit_M= []; for i=1:length(bit) bit_M = [bit_M bit(i)*ones(1,M)]; % Oversampled bit stream end p_NRZ(1:M)=1; % NRZ pulse p_RZ(1:M/2)=1; p_RZ(M/2:M)=0; % RZ pulse p_M(1:M/2)=-1; p_M(M/2:M)=1; % Manchester pulse % (a) Unipolar NRZ for i=1:length(bit) for j=(i-1)*M+1:i*M s_UNRZ(j) = bit(i)*A*p_NRZ(j-(i-1)*M); end end % (b) Unipolar RZ for i=1:length(bit) for j=(i-1)*M+1:i*M s_URZ(j) = bit(i)*A*p_RZ(j-(i-1)*M); end end % (c) Polar NRZ for i=1:length(bit) for j=(i-1)*M+1:i*M s_PNRZ(j) = polar(bit(i)+1)*p_NRZ(j-(i-1)*M); end end % (d) Polar RZ for i=1:length(bit) for j=(i-1)*M+1:i*M s_PRZ(j) = polar(bit(i)+1)*p_RZ(j-(i-1)*M); end end % (e) AMI NRZ st = [-A*ones(1,M)]; % Inital amplitude -A for i=1:length(bit) if bit(i), st = -st; end for j=(i-1)*M+1:i*M AMI_NRZ(j) = bit(i)*st(j-(i-1)*M)*p_NRZ(j-(i-1)*M); end end % (f) AMI RZ st = [-A*ones(1,M)]; % Inital amplitude -A for i=1:length(bit) if bit(i), st = -st; end for j=(i-1)*M+1:i*M AMI_RZ(j) = bit(i)*st(j-(i-1)*M)*p_RZ(j-(i-1)*M); end end % (g) Manchester for i=1:length(bit) for j=(i-1)*M+1:i*M s_M(j) = polar(bit(i)+1)*p_M(j-(i-1)*M); end end % Plot all signals subplot(7,1,1) plot(t,bit_M,'k'); ylabel ('Bits'); axis ([ 0 T_bits -0.1 1.1 ]) set(gca,'YTick',[0 1]), grid on title('Examples of line coding schemes - SJSU - EE161') subplot(7,1,2) plot(t,s_UNRZ,'k'); ylabel ('U-NRZ'); axis ([ 0 T_bits -0.1*A 1.1*A ]), grid on subplot(7,1,3) plot(t,s_URZ,'k'); ylabel ('U-RZ'); axis ([ 0 T_bits -0.1*A 1.1*A ]), grid on subplot(7,1,4) plot(t,AMI_RZ,'k'); ylabel ('AMI-RZ'); axis ([ 0 T_bits -1.1*A 1.1*A ]), grid on subplot(7,1,5) plot(t,s_PNRZ,'k'); ylabel ('P-NRZ'); axis ([ 0 T_bits -1.1*A 1.1*A ]), grid on subplot(7,1,6) plot(t,s_PRZ,'k'); ylabel ('P-RZ'); axis ([ 0 T_bits -1.1*A 1.1*A ]), grid on subplot(7,1,7) plot(t,s_M,'k'); ylabel ('Manchester'); axis ([ 0 T_bits -1.1*A 1.1*A ]), grid on linecodingdemo Execution of script linecodingdemo as a function is not supported: /MATLAB Drive/EE161/linecodingdemo.m
Error in linecoding (line 9)
Enter your student ID: 015084355
  4 Comments
Luca Ferro
Luca Ferro on 9 Feb 2023
Edited: Luca Ferro on 9 Feb 2023
i'm quite confused by the naming. Is the script named 'line_coding.m' as stated in the description, 'linecodingdemo.m' as stated in the which statement or 'linecoding.m' as you are trying to call from command window?
This is relevant :
  • because i think you are calling the wrong script
  • because i think you have multples on the same path and that creates conflict
Yubin Hwang
Yubin Hwang on 9 Feb 2023
I used same filename line_coding.m but it has an error so I changed

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 9 Feb 2023
when the code emits the message about entering the student ID, the person running the code needs to type in a numeric student number. The person running the code must not type in the script name again at that point: the script is already running.
  1 Comment
VBBV
VBBV on 9 Feb 2023
You are right. The error is perhaps due to the below line
rand('state',seed)
When Matlab tries to run above line , it takes the user input and assigns to seed which in turn goes as input to rand function. That's when Matlab gets confused and throws error.

Sign in to comment.

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!