In the image, no is a function of T and Lambda and is constant for particular value of T and lambda. However i need a plot of lambda which is output variable(on axis) and T which is input variable(on X axis). How can i do it.

1 次查看(过去 30 天)

采纳的回答

Image Analyst
Image Analyst 2015-1-2
The easiest way for you is to probably just do a double for loop over the values you want.
T = linspace(0, 300, 100); % Or whatever
lambda = linspace(2,5,100); % Whatever...
for t = 1 : length(T)
for k = 1 : length(lambda)
thisT = T(t);
thisLambda = lambda(k);
no(k, t) = ..... your formula......
end
end
imshow(no, []);
colormap(jet(256));
You can also do it vectorized if you use meshgrid() but it's a little trickier and harder to understand for beginners.
  4 个评论
Image Analyst
Image Analyst 2015-1-3
Well, now the numbers are right. I have no idea what this function is supposed to look like, don't you? Is your equation for T correct? But in your equation for no, you're supposed to use thisT, not t, and use thisW_2 instead of k. Here is corrected code:
clc;
clear all;
close all;
fontSize = 20;
T = linspace(135, 160, 500); %----Temperature varying from 135C to 160C--%
W_2 = linspace(1.3e-6, 2.2e-6, 500); %------wavelength ranging from 1.3microns to 2.2microns----%
for t=1:length(T);
thisT = T(t);
for k=1:length(W_2);
thisW_2 = W_2(k);
term1 = 4.9048+2.1429e-8.*(thisT^.2-88506.25);
numerator = 0.11775+2.2314e-8.*(thisT.^2-88506.25);
denominator = thisW_2.^2 - (0.21802-2.9671e-8.*(thisT.^2-88506.25)).^2;
term4 = -0.027153.*thisW_2.^2;
no(k, t) = term1 + numerator/denominator + term4;
end
end
imshow(no,[]);
colormap(jet(256));
xlabel('T, degrees Celsius', 'FontSize', fontSize);
ylabel('Wavelength, Lambda', 'FontSize', fontSize);
Image Analyst
Image Analyst 2015-1-3
I'd advise you to view this link and then look at each term to determine if it's correct. Look at the value of the variable no (which is really no^2 according to your formula) and discover if you got the expected value. This is basic debugging so it's something you can do, or should know how to do, so I'll leave it up to you because it's an essential skill that you'll have to learn one day anyway. Good luck.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by