필터 지우기
필터 지우기

How can I run this code I don't know where is the fault?

조회 수: 1 (최근 30일)
Akhtar Jan
Akhtar Jan 2022년 3월 30일
댓글: Arif Hoq 2022년 3월 30일
clc
close all
clf
k1 = 2;
k_1 = 1;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 1;
St = 100;
K1 = (k_1+k2)/(k1*St);
K2 = (k_3+k4)/(k3*St);
E1t = 20;
E2t = 30;
v = (k2*E1t)/(k4*E2t);
P = ((v-1)-K2*(v+K1/K2))+sqrt((v-1)-K2*(v+K1/K2)^2+4*K2*v*(v-1))/2*(v-1);
S = St - P;
pt1 = plot(v,P,'r');
Warning: Imaginary parts of complex X and/or Y arguments ignored.
hold on
pt2 = plot(v, S,'g');
Warning: Imaginary parts of complex X and/or Y arguments ignored.

채택된 답변

Arif Hoq
Arif Hoq 2022년 3월 30일
편집: Arif Hoq 2022년 3월 30일
As your output is a scalar value so you need to define it with Marker. and you are plotting only real values
k1 = 2;
k_1 = 1;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 1;
St = 100;
K1 = (k_1+k2)/(k1*St);
K2 = (k_3+k4)/(k3*St);
E1t = 20;
E2t = 30;
v = (k2*E1t)/(k4*E2t);
P = ((v-1)-K2*(v+K1/K2))+sqrt((v-1)-K2*(v+K1/K2)^2+4*K2*v*(v-1))/2*(v-1);
S = St - P;
pt1 = plot(v,P,'o');
Warning: Imaginary parts of complex X and/or Y arguments ignored.
hold on
pt2 = plot(v, S,'*');
Warning: Imaginary parts of complex X and/or Y arguments ignored.
  댓글 수: 4
Arif Hoq
Arif Hoq 2022년 3월 30일
try this for imaginary and real value
plot(v,real(P),'o'); % real part of P
hold on
plot(imag(P),'s') % imaginary part of P
hold on
plot(v, real(S),'*'); % real part of S
hold on
plot(imag(S),'d') % imaginary part of S
xlim([0 2])
Arif Hoq
Arif Hoq 2022년 3월 30일
for continious graph use linspace
k1 = 2;
k_1 = 1;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 1;
St = 100;
K1 = (k_1+k2)/(k1*St);
K2 = (k_3+k4)/(k3*St);
E1t = 20;
E2t = 30;
v = (k2*E1t)/(k4*E2t);
P = ((v-1)-K2*(v+K1/K2))+sqrt((v-1)-K2*(v+K1/K2)^2+4*K2*v*(v-1))/2*(v-1);
S = St - P;
t=linspace(0,5,100);
plot(t,real(P),'o'); % real part of P
hold on
% plot(t,imag(P),'s') % imaginary part of P
% hold on
plot(t, real(S),'*'); % real part of S
% hold on
% plot(t,imag(S),'d') % imaginary part of S
% xlim([0 2])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by