Calculate and Plot Fourier function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi there,
I have made some calculation on paper and would like to visualise the result by plotting it in MATLAB. However I can't seem to get result that I expect. I have attached a screenshot of the function and the code that I have until now. I would very much appreciate some help on with this.
%
clear;
clc;
%
Fs = 10000000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 0.01; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%
n = 1:50;
%
Fm = 1e3; %Signal frequency for omega(m).
Fc = 100e3; %Signal frequency for omega(c).
Am = 1/10;
Ac = 5/10;
%
A1 = Am*Ac/2*(sin(2*pi*Fc*t));
A2 = Am*Ac/pi;
A3 = A1-A2;
A4 = cos(n*2*pi*Fm*t-2*pi*Fc*t);
A5 = cos(n*2*pi*Fm*t+2*pi*Fc*t);
%
A6 = A3-1/n*((A4-A5));
%
0 comentarios
Respuestas (1)
nanren888
el 1 de Abr. de 2017
Editada: nanren888
el 1 de Abr. de 2017
>> tmp01 Error using * Inner matrix dimensions must agree.
Error in tmp01 (line 17) A4 = cos(n*2*pi*Fm*t-2*pi*Fc*t);
>>
Is this what you mean?
Posting the error will help people see where you are & give you an answer that is useful to you. . The error appears because n is a row vector ([50,1]) & t is a column ([100000,1]) You tell Matlab to do the multiply n*...*t & the inner dimensions don't match. (Which they shouldn't)
Did you intend to an outer product? to create a resulting matrix ([50,100000])? or perhaps its transpose?
If so, transposing each of them might help, or swapping the order of the multiplications?
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!