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');
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!