Signal plot - Can't figure out error

2 ビュー (過去 30 日間)
STP
STP 2019 年 4 月 2 日
コメント済み: KSSV 2019 年 4 月 2 日
t1= [0 5];
t2a = [5 6];
t2b = [6 7];
t3 = [7 10];
Eo1 = exp(1i*pi);
phi = 2*pi/3; % any angle as its the slope
k = -phi/(t2a(1)-t1(1));
Eo2a = @(t)exp(1i*(phi + k*(t-t1(1))));
Eo2b = exp(1i*0);
Eo3 = 0;
t= [t1; t2a; t2b; t3];
Eo = [Eo1; Eo2a(t2a); Eo2b; Eo3];
%% this should be the figure below.
plot(t, real(Eo), 'DisplayName','Real')
plot(t, imag(Eo), 'DisplayName','Im')
legend
What am I doing wrong? -- as I don't get the below plot Eo as outcome
  5 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 2 日
You define k in terms of t2a(1) and t1(1) . That implies you think t1 and t2a are vectors.
You define Eo1 as a scalar constant.
You define Eo2a as a function handle, and pass the vector t2a to it, getting back a vector of results. It might be a row vector rather than a column vector. When you try to use [A;B] between a scalar and a row vector, that is not going to work.
STP
STP 2019 年 4 月 2 日
編集済み: STP 2019 年 4 月 2 日
I edited as per your comments - but still no output
t1= [0 5];
t2a = [5 6];
t2b = [6 7];
t3 = [7 10];
Eo1 = exp(1i*pi);
phi = 2*pi/3; % any angle as its the slope
k = -phi/(t2a(1)-t1(1));
Eo2a = @(t)exp(1i*(phi + k*(t-t1(1))));
Eo2b = exp(1i*2*pi);
Eo3 = 0;
t= [t1; t2a; t2b; t3];
Eo = [Eo1; Eo2a; Eo2b; Eo3];
%% this should be the figure below.
plot(t, real(Eo), 'DisplayName','Real')
plot(t, imag(Eo), 'DisplayName','Im')
legend
It is basically this that would give out the plot shown above-
Capture.JPG

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2019 年 4 月 2 日
Eo2a is a function handle...you have to input t and get output. You should run something like below. REthink on your code.
t1= [0 5];
t2a = [5 6];
t2b = [6 7];
t3 = [7 10];
Eo1 = exp(1i*pi);
phi = 2*pi/3; % any angle as its the slope
k = -phi/(t2a(1)-t1(1));
Eo2a = @(t)exp(1i*(phi + k*(t-t1(1))));
Eo2b = exp(1i*2*pi);
Eo3 = 0;
t= [t1; t2a; t2b; t3];
Eo = [Eo1 Eo2a(t1) Eo2b ];
%% this should be the figure below.
plot(t, real(Eo), 'DisplayName','Real')
plot(t, imag(Eo), 'DisplayName','Im')
legend
  2 件のコメント
STP
STP 2019 年 4 月 2 日
編集済み: STP 2019 年 4 月 2 日
Hi, KSSV; thanks for your input - I tried this way too- but I still don't get this output (Eo)
KSSV
KSSV 2019 年 4 月 2 日
I have only solved the error.....didn't work on the real problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by