How to overlap two plots on Matlab?
Show older comments
Here is my code so far. I keep on getting the error in line 24, what am I doing wrong?
%plot vega2.txt spectrum it vs wavelength in meters.
a=dlmread('vega2.txt'); [n nc]=size(a);
x= a(:,1);
y= a(:,2);
plot(x,y,'-');
title('Vega Function');
xlabel('wavelength');
ylabel('spectrum');
%Use the theory of blackbody radiation (Wien displacement law) to estimate the
%temperature of this star (in units of K) showing your work.
lmax=max(x);
h=6.62606957*(10^-34);
c= 2.99792458*(10^8);
kb=1.3806581*(10^-23);
Star_Temp=(lmax*4.965*kb)/(h*c)
%Make a plot which overlays a scaled blackbody spectrum (equation in text)
%with the spectrum of Vega showing that your temperature is reasonable.
p=8*pi*h*c*(x^-5)*(exp((h*c)/(x*kb*T))-1)^-1
subplot(x,p,'-');**
>>Error in PChem_Hmk1_P3 (line 24)
p=8*pi*h*c*(x^-5)*(exp((h*c)/(x*kb*T))-1)^-1;
1 Comment
Walter Roberson
on 25 Aug 2013
You did not indicate what the error message is ?
Answers (2)
Walter Roberson
on 25 Aug 2013
0 votes
Remember to use .* and .^ and ./ when you want element-by-element computation on vectors. For example, (x.^-5).* ...
Luca
on 15 Jan 2014
0 votes
You didn't declare the variable T.
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!