How to overlap two plots on Matlab?
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 25 Aug. 2013
You did not indicate what the error message is ?
Antworten (2)
Walter Roberson
am 25 Aug. 2013
0 Stimmen
Remember to use .* and .^ and ./ when you want element-by-element computation on vectors. For example, (x.^-5).* ...
Luca
am 15 Jan. 2014
0 Stimmen
You didn't declare the variable T.
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!