Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

KSSV
KSSV il 20 Ago 2020
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);

Più risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by