Plotting a function with 3 differing initial values
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nicholas Davis
el 29 de En. de 2021
Respondida: Shubham Khatri
el 3 de Feb. de 2021
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');
0 comentarios
Respuesta aceptada
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.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!