Info

This question is closed. Reopen it to edit or answer.

I want to generate a sinusoidal signal with following lines of programme. It shows the error "Matrix dimensions must agree." Why is this error and what is the solution?

1 view (last 30 days)
N=512; %length of the signal n=0:N-1; phase=30; phase_in_rad=degtorad(phase); final_phase=phase_in_rad*(1:9);
x=sin(2*pi*(25/N)*n+(final_phase))+sin(2*pi*(60/N)*n+(final_phase))+cos(2*pi*(110/N)*n-(final_phase));
figure; subplot(2,1,1); plot(x,'g') grid on; xlabel('Samples'); ylabel('Amplitude of the signal'); title('Main Signal');
xf=fft(x);
xfmag=10*log10(abs(xf));
subplot(2,1,2); plot(abs(xf),'r') grid on; xlabel('Samples'); ylabel('Amplitude'); title('Absolute value of FFT of x');

Answers (0)

Community Treasure Hunt

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

Start Hunting!