필터 지우기
필터 지우기

Plotting a function with 3 differing initial values

조회 수: 1 (최근 30일)
Nicholas Davis
Nicholas Davis 2021년 1월 29일
답변: Shubham Khatri 2021년 2월 3일
Hi all. I am trying to plot a function with 3 different scale values, so I'd like to produce a line for each scale value (included in code as a vector, notated as lambda on plot legend), though I am unsure of how to go about it. Thanks!
% Initial Values
m = linspace(0,1,10^6);
scale = [ 0.1 0.04 0.02 ];
% The Workzone
[K,E] = ellipke(m); % Elliptical Integral of First and Second Kind
% Axes for Plotting
xaxis = -1*log10(1-m);
yrecip = sqrt(8*K.*scale^2.*(K-E));
yaxis = 1./yrecip;
% Plotting
clf; figure(1);
plot(xaxis,yaxis,'-k');
% Axes
colororder({'k','k'});
xlim([-.25,15.5]); ylim([0,8]);
xlabel('-log10(1-m)'); ylabel('(8K(m)(\lambda)^2(K(m)-E(m))^-1/2');
yyaxis right
ylim([0,8]);
ylabel('j');
grid on
legend('\lambda = 1/25')
% title('Graphical Solution of Eq.15');

채택된 답변

Shubham Khatri
Shubham Khatri 2021년 2월 3일
Hello,
To my understanding of the question and code, I find that the dimension of scale is not correct thats why it is creating error. Also, while defining the variable yrecip the 'scale' should be dot multiplied/squared. I have pasted the corrected code below.
% Initial Values
m = linspace(0,1,10^6);
scale = 0.0000001:0.000001:1;
% The Workzone
[K,E] = ellipke(m); % Elliptical Integral of First and Second Kind
% Axes for Plotting
xaxis = -1*log10(1-m);
yrecip = sqrt(8*K.*(scale.^2).*(K-E));
yaxis = 1./yrecip;
% Plotting
clf; figure(1);
plot(xaxis,yaxis,'-k');
% Axes
colororder({'k','k'});
xlim([-.25,15.5]); ylim([0,8]);
xlabel('-log10(1-m)'); ylabel('(8K(m)(\lambda)^2(K(m)-E(m))^-1/2');
yyaxis right
ylim([0,8]);
ylabel('j');
grid on
legend('\lambda = 1/25')
% title('Graphical Solution of Eq.15');
Hope it helps.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by