Matlab Homework: Plotting T vs λ with Max Function and Stylish Design

In summary, the conversation discusses a function and how to use it to draw curves with specific values. The conversation also mentions using the max function and avoiding repetition of code. The goal is to create a stylish image with neatly placed text above the maximum points. The code provided includes the use of the text function to write the corresponding curve values.
  • #1
Pouyan
103
8

Homework Statement



I have a function :
latex1.gif

and I want to draw :
intensity.png

Homework Equations



where T has values : 600, 800, 1000, 1100 And λ:(0,10*^-5] I have to use max function with two values and the solution must not consist of repeating four times of similar snippets of code, one for each curve.The image should be stylish. For example. so the texts may not cut curves, but neatly placed just above the maximum point.

The Attempt at a Solution


[/B]
This is the way how I start :
F=@(L,T) 3.7415E-16 ./((L.^5).*(exp(0.014 ./(L.*T))-1));
T=[600, 800, 1000, 1100];
L=0:10^-6:10^-5;
[Lm Tm]=meshgrid(L,T);
fm=F(Lm,Tm);
plot(L,fm)
hold on
grid on
[Y I]=max(fm);
plot(L(I),Y,'*')
And I get :
https://se.mathworks.com/matlabcentral/answers/uploaded_files/70252/image1.bmp
My question is how should I use text function in Matlab to write T for correspond curve
 
Physics news on Phys.org
  • #2
This how I could develop the code but I fail with one thing !

clear all

clc

F=@(L,T) 3.7415E-16 ./((L.^5).*(exp(0.014 ./(L.*T))-1));

T=[600 800 1000 1100];

L=0:10^-7:10^-5;

[Tm Lm]=meshgrid(T,L);

fm=F(Lm,Tm);

plot(L,fm)

grid on

[Y I]=max(fm);

hold on

plot(L(I),Y,'*')

%text(L(I),Y,'T= ')

hold on

for i=1:1:4

S=['T= ',num2str(T(i))]

N = L(I)-1.E-7;

G = Y+5.E8;
text(N,G, S)
end

I get this image as result :

https://se.mathworks.com/matlabcentral/answers/uploaded_files/70256/image2.bmp
 

FAQ: Matlab Homework: Plotting T vs λ with Max Function and Stylish Design

What is Matlab and how is it used for plotting?

Matlab is a high-level programming language and interactive computing environment commonly used for scientific and numerical computations. It has built-in functions and tools specifically designed for plotting and visualizing data, making it a powerful tool for data analysis and visualization.

How do I plot data in Matlab?

To plot data in Matlab, you can use the "plot" function, which takes in two arrays as inputs - one for the x-values and one for the y-values. You can also customize the plot by adding labels, titles, and adjusting the color and style of the plot using different optional parameters.

Can I plot multiple graphs on one figure in Matlab?

Yes, you can plot multiple graphs on one figure in Matlab by using the "hold on" command after each plot function. This will allow you to plot multiple graphs on the same figure without erasing the previous plot.

How do I save my plots in Matlab?

To save your plots in Matlab, you can use the "saveas" function, which allows you to specify the file format and name of the plot. You can also use the "print" function to save the plot as an image file.

Are there any other types of plots available in Matlab?

Yes, Matlab offers a variety of different plot types, including scatter plots, bar graphs, histograms, and more. You can also use the "subplot" function to create multiple plots within one figure.

Similar threads

Replies
10
Views
2K
Replies
1
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
4K
Replies
4
Views
3K
Back
Top