plotting real and imaginary parts

4 vues (au cours des 30 derniers jours)
Martina Grima
Martina Grima le 19 Mai 2020
I was working the following questions and got into some difficulties. I don't think what I have written so far is correct and I don't know how to continue. I have worked until question C. There is a misprint in the empirical characteristic function. The i should be a j. It should be taken that sigma is 4 throughout these questions.
%Question A
clear all
clc
a=random('normal',4,1,100,1);
b=random('normal',4,1,300,1);
c=random('normal',4,1,1000,1);
%Question B & C
% initializing vectors to store points
first = zeros(1,100);
second = zeros(1,300);
third = zeros(1,1000);
f = zeros(1,7);
% setting count as 1 to initialise the figures
count = 1;
% we will vary t from -3 till 3 and obatin a plot for each
for t = -3:1:3
% loop to get points of phi_n_(t) using vector a of size 100
for j = 1:100
first(1,j) = (1/size(a,1))*(cos(t*a(j,1)) + sqrt(-1)*sin(t*a(j,1)));
%real and imaginary parts of the points obtained above
realfirst = real(first);
imfirst = imag(first);
end
% loop to get points of phi_n_(t) using vector b of size 300
for k = 1:300
second(1,k) = (1/size(b,1))*(cos(t*b(k,1)) + sqrt(-1)*sin(t*b(k,1)));
%real and imaginary parts of the points obtained above
realsec = real(second);
imsec = imag(second);
end
% loop to get points of phi_n_(t) using vector c of size 1000
for h = 1:1000
third(1,h) = (1/size(c,1))*(cos(t*c(h,1)) + sqrt(-1)*sin(t*c(h,1)));
%real and imaginary parts of the points obtained above
realthird = real(third);
imthird = imag(third);
end
% plot of phi_(t)
f(1,count) = exp((sqrt(-1)*1*t) - (t/2));
realf = real(f);
imf = imag(f);
figure(count)
% plot(sum(realfirst),sum(imfirst),'r*',sum(realsec),sum(imsec),'b*', sum(realthird), sum(imthird),'g*',realf,imf,'y')
plot(realfirst,imfirst,'r*',realsec,imsec,'b*',realthird,imthird,'g*',realf,imf,'y')
% points in red are for vector a of size 100
% points in blue are for vector b of size 300
% points in green are for vector c of size 1000
% can be seen that the yellow line of phi_(t) converges towards the
% centre of the circles plotted of phi_n_(t)
count = count+1;
end
  1 commentaire
darova
darova le 20 Mai 2020
So you have
and function
so what is the problem?
t = -3:0.1:3;
phi = exp(1i*mu*t-sigma^2*t/2);
plot(t,imag(phi),t,real(phi))
simple?

Connectez-vous pour commenter.

Réponses (1)

kalaiselvi p
kalaiselvi p le 25 Avr 2022
t = -3:0.1:3;
phi = exp(1i*mu*t-sigma^2*t/2);
plot(t,imag(phi),t,real(phi))

Catégories

En savoir plus sur Descriptive Statistics and Visualization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by