Calculate and Plot Fourier function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
nanren888
il 1 Apr 2017
Modificato: nanren888
il 1 Apr 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 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing 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!