Plotting a function with 3 differing initial values

1 visualización (últimos 30 días)
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');

Respuesta aceptada

Shubham Khatri
Shubham Khatri el 3 de Feb. de 2021
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.

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by