How to improve my code for getting the output in the picture?
2 次查看(过去 30 天)
显示 更早的评论
I want a output similar to this
the code I wrote is
R=1.09677*10^7;
p=1;
n=2;
Z=1
for n= 2:9
n=n+1;
k=R*Z^2*[1/(p^2)-1/(n^2)];
lamda=1/k
y=linspace(0,7*10^-9,20)
plot(lamda,y)
hold on
daspect([1,1,1])
endfor
here i am getting output as groups of points since i wrote plot(lamda,y)
- what can i do to get a line instead of group of points
- how to change the background to black
- is there any way to change the colour of the line (plot) according to the wavelength
- can we change the thickness?
0 个评论
采纳的回答
Star Strider
2017-12-10
Try this:
R=1.09677E+7;
p=1;
n=2;
Z=1;
for n= 2:9
n=n+1;
k=R*Z^2*[1/(p^2)-1/(n^2)];
lamda=1/k;
y=linspace(0,7E-9,20);
plot(lamda*ones(size(y)),y)
hold on
daspect([1,1,1])
end
set(gca, 'Color','k')
2 个评论
Star Strider
2017-12-10
Try this:
R=1.09677E+7;
p=1;
n=2;
Z=1;
cm = colormap(jet(9));
for n= 2:9
k=R*Z^2*[1/(p^2)-1/(n^2)];
lamda=1/k;
y=linspace(0,7E-9,20);
plot(lamda*ones(size(y)),y, 'Color',cm(n,:), 'LineWidth',2)
hold on
end
daspect([1,1,1])
axis([xlim 0 max(y)])
set(gca, 'Color','k')
See the documentation on colormap to understand its options.
Experiment to get the result you want.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!