Plotting a function with 3 differing initial values

1 次查看(过去 30 天)
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 中查找有关 Animation 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by