How to overlap two plots on Matlab?
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 25 Août 2013
You did not indicate what the error message is ?
Réponses (2)
Walter Roberson
le 25 Août 2013
0 votes
Remember to use .* and .^ and ./ when you want element-by-element computation on vectors. For example, (x.^-5).* ...
Luca
le 15 Jan 2014
0 votes
You didn't declare the variable T.
Catégories
En savoir plus sur Line Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!