フィルターのクリア

How to plot a graph using if function

3 ビュー (過去 30 日間)
Seb apple
Seb apple 2020 年 7 月 15 日
編集済み: Adam Danz 2020 年 7 月 16 日
Hi i am trying to plot a graph but not sure how to go about it. I want to plot a graph from my code of e against q where the value for absL(1) <= 1 is a shaded region or at least creates the boarder. this is my code so far i think i would use if function but not sure.
syms e q L
c= 1;
f(t)=(e-(2*q)*cos(2*t));
M=[0 1; -f(t) -c];
%*[x1; x2];
N=trace(M);
P=det(M);
(L^2)-(N*L)+P==0;
L(1) = (N+sqrt((N^2)-(4*P)))/2;
L(2) = (N-sqrt((N^2)-(4*P)))/2;
if abs(L(1)) <= 1

回答 (1 件)

Adam Danz
Adam Danz 2020 年 7 月 15 日
編集済み: Adam Danz 2020 年 7 月 16 日
I don't see any plotting commands so I don't know what kind of plot you're trying to create.
The problem can likely be solved by indexing. Spend some time on that page. Indexing is one of the main features of matlab.
For example,
idx = abs(L) <= 1;
plot(q(idx),e(idx), 'ro')
hold on
plot(q(~idx),e(~idx), 'bo')

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by