フィルターのクリア

Subscript indices must either be real positive integers or logicals. where I have to change or update the code

1 回表示 (過去 30 日間)
clc;
clear all;
close all;
Transmitted_Message = 'SP22';
dec = double(Transmitted_Message); % text to ASCII (decimal)
p2 = 2.^(0:-1:-7); % 2^0,2^-1,.......,2^-7
B = mod(floor(p2'*dec),2); % decimal to binary conversion
% columns of B are bits of characters
x = reshape(B,1,numel(B));
disp('Transmitted message is:')
disp(Transmitted_Message)
disp('Binary information at Transmitter:');
disp(x);
F=1;
G=9;
%my id is 19-39319-1
br=(F+G+2)*200;
bp = 1/br;% bit period
%% representation of transmitting binary information as digital % signal
bit = [];
a0 = 12; % amplitude for binary bit 00
a1 = 16; % amplitude for binary bit 01
a2=20; % amplitude for binary bit 10
a3=24;% amplitude for binary bit 11
nt = 1000; % number of samples in a single bit period
for n =linspace(1,2,length(x))
if x(n) == 0 && x(n+1)== 0 ;
se = a0*ones(1,nt);
elseif x(n) == 0 && x(n+1)== 1;
se = a1*ones(1,nt);
elseif x(n) == 1 && x(n+1)== 0;
se = a2*ones(1,nt);
else x(n) == 1 && x(n+1)== 1;
se = a3*ones(1,nt);
end
bit = [bit se];
end
t = linspace(0, bp/nt, length(x)*bp-bp/nt));
plot (t,bit,'lineWidth',2);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Transmitting information as digital signal');

採用された回答

Shnigdha Sharup
Shnigdha Sharup 2021 年 8 月 4 日
remove linspace . write 2*bp/nt insted of bp/nt in t.

その他の回答 (1 件)

Asaad Abboud Alkhalaf
Asaad Abboud Alkhalaf 2021 年 8 月 3 日
instead of for n =linspace(1,2,length(x))
use for n= 1:2:length(x) if you want vector with elements spaced by 2
or for n=1:length(x) if you want vector with ellemnts spaced by1

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by