Error: In an assignment A(:) = B, the number of elements in A and B must be the same.

3 次查看(过去 30 天)
Can someone please help me to correct the above mentioned problem in the following matlab code ?
T = 5; %period
sample = 44100*20; % samples
period = 4; %required number of periods
SinglePeriod = linspace (0, T, 44100*5 + 1); %single period
SinglePeriod(end) = []; %time vetor
t = linspace(0, T*period, sample+1); %time vector required
t(end) = [];
s3 = zeros(1, period);
s3(SinglePeriod >= 0 & SinglePeriod < 2.5) = ((A*SinglePeriod)/4);
s3(SinglePeriod >= 2.5 & SinglePeriod < 5) = (((-A*SinglePeriod)+(5*A))/4);
The 'entire' error message is:
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in mission (line 66)
s3(SinglePeriod >= 0 & SinglePeriod < 2.5) = ((A*SinglePeriod)/4);

采纳的回答

KSSV
KSSV 2020-8-20
T = 5; %period
sample = 44100*20; % samples
period = 4; %required number of periods
SinglePeriod = linspace (0, T, 44100*5 + 1); %single period
SinglePeriod(end) = []; %time vetor
t = linspace(0, T*period, sample+1); %time vector required
t(end) = [];
s3 = zeros(1, period);
s3(SinglePeriod >= 0 & SinglePeriod < 2.5) = ((A*SinglePeriod(SinglePeriod >= 0 & SinglePeriod < 2.5))/4);
s3(SinglePeriod >= 2.5 & SinglePeriod < 5) = (((-A*SinglePeriod(SinglePeriod >= 2.5 & SinglePeriod < 5))+(5*A))/4);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by