Question

In: Physics

The resistance R of a tungsten wire as a function of temperature can be modeled with...

The resistance R of a tungsten wire as a function of temperature can be modeled with the equation

R=R0*[1+α(T-T0 )

whereR0 is the resistance corresponding to temperature T0, and α is the temperaturecoefficient of resistance. Determine R0and α such that the equation will best fit the following data (Use linear regression curve fitting). Take T0 = 20°C.

T=[20 100 180 260 340 420 500]

R=[500 676 870 1060 1205 1410 1565]

After enter below codes it gives an error

function [a,Er]=LinReg(x,y)

[rowx,colx]=size(x);
%x=[20 100 180 260 340 420 500];

[rowy,coly]=size(y);
%y=[500 676 870 1060 1205 1410 1565];
m=colx;
n=coly;
if m~=n
error('Size Of x And y Have to be Same');
end
sumx=0;
for i=1:m
sumx=sumx+x(i);

end
%display(sumx);
sumy=0;
for i=1:m
sumy=sumy+y(i);
  
end
%display(sumy);
sumx_2=0;
for i=1:m
sumx_2=sumx_2+(x(i).^2);
end
%display(sumx_2);
sumxy=0;
for i=1:m
sumxy=sumxy+(x(i).*y(i));

end
%display(sumxy);
a_1=((n.*sumxy)-(sumx.*sumy))/((n.*sumx_2)-((sumx).^2));
a_0=(((sumx_2).*(sumy))-((sumxy).*(sumx)))/((n.*sumx_2)-((sumx).^2));
a(1)=a_1;
a(2)=a_0;
Er=0;
for i=1:m
Er=Er+(((y(i)-(a_1.*x(i)+a_0))).^2);
end
end

%ERROR:

Not enough input arguments.

Error in LinReg1 (line 3)
[rowx,colx]=size(x);

Solutions

Expert Solution

So, if we want to fit a linear regression line,

I am using the following simple linear regression formulae:

for a linear regression model: y = a + b*x,

where, b is slope and a is intercept

matlab code:

%%%%%%%% function LinReg.m %%%%%%

function [R0,alpha,SSE,SST,Rsq] = LinReg(x,y,T0)
n = length(x);
m = length(y);
if n ~= m
disp('x and y are of different lengths, regression will be inaccurate; proceeding anyhow...\n');
if n > m
n = m;
end
end
x_avg = sum(x(1:n))/n;
y_avg = sum(y(1:n))/n;
num = 0.0; % stands for numerator
denom = 0.0; % stands for denominator
for i = 1:n
num = num + (x(i) - x_avg)*(y(i) - y_avg);
denom = denom + (x(i) - x_avg)^2;
end
slope = num/denom;
intercept = y_avg - slope*x_avg;
R0 = intercept + slope*T0;
alpha = slope/R0;
SSE = 0.0; % sum of squared error
SST = 0.0; % total sum of squares
for i = 1:n
SSE = SSE + (y(i) - intercept - slope*x(i))^2;
SST = SST + (y(i) - y_avg)^2;
end
Rsq = (SST - SSE)/SST;
end

%%%%%%% end of LinReg.m %%%%%%

%%%%%%% main.m %%%%%%

T = [20 100 180 260 340 420 500];
R = [500 676 870 1060 1205 1410 1565];
T0 = 20;
[R0,alpha,SSE,SST,Rsq] = LinReg(T,R,T0);
fprintf('R0 = %f\n',R0);
fprintf('alpha = %f\n',alpha);
fprintf('SSE = %f\n',SSE);
fprintf('SST = %f\n',SST);
fprintf('SSR = %f\n',SST-SSE);
fprintf('Rsq = %f\n',Rsq);

%%%%%%%% end of main.m %%%%%%

screenshots of code:

LinReg.m :

main.m :

output:

We see that Rsq is very close to 1. So the fit is a good fit.

----------------------X------------------------X---------------------X--------------------

If you find this answer helpful, please give it a thumbs up. Thank you.


Related Solutions

A given copper wire has a resistance of 5.10 ? at 20.0°C while a tungsten wire...
A given copper wire has a resistance of 5.10 ? at 20.0°C while a tungsten wire of the same diameter has a resistance of 4.67 ? at 20.0°C. At what temperature will the two wires have the same resistance?
A thin tungsten wire (i.e. a filament) is heated to a given temperature T. In the...
A thin tungsten wire (i.e. a filament) is heated to a given temperature T. In the visible range (i.e. wave length between 0.39µm and 0.77µm), Determine the following for the four cases listed below: (a) the band fraction of emitted radiation energy (b) the blackbody radiation energy emitted The four cases correspond to to following values of T: (i) T=500K (ii) T=1500K (iii)T=2500K (iv) T=3500K The melting temperature of tungsten is 3698K. Show all calculation details.
In a machine that temperature changes from 20 ∘C up to 120 ∘C a tungsten wire...
In a machine that temperature changes from 20 ∘C up to 120 ∘C a tungsten wire filament 13.0 cm long with a diameter of 1.20 mm will be used. The wire will carry  11.0 A at all temperatures ( Resistivity of tungsten at 20 ∘C is 5.25×10^−8Ω⋅m , the temperature coefficient of resistivity at 20 ∘C is 0.0045 ∘C^−1 ). A-)Calculate the maximum electric field in this filament? B-)Calculate the resistance of the filament  with that field? C-)Calculate the maximum potential drop...
Outside temperature over a day can be modeled as a sinusoidal function. Suppose you know the...
Outside temperature over a day can be modeled as a sinusoidal function. Suppose you know the high temperature of 92 degrees occurs at 3 PM and the average temperature for the day is 85 degrees. Find the temperature, to the nearest degree, at 10 AM. Please provide step by step how to find x after finding equation
Consider the blackbody radiation emitted at a temperature of 500◦C. (i) Explain why a tungsten wire...
Consider the blackbody radiation emitted at a temperature of 500◦C. (i) Explain why a tungsten wire in an old-fashioned light-bulb starts to glow as it becomes sufficiently hot. (ii) Calculate the percentage pressure increase of the blackbody radiation if the temperature is raised to 550◦C. An electron escapes the hot tungsten wire and is subsequently trapped in a one-dimensional square quantum well. The potential outside the well can be approximated as infinite. (iii) Sketch the probability distribution of the electron...
Q1) A metal wire has a resistance of 10.0 at a temperature of 20,0 °C. If...
Q1) A metal wire has a resistance of 10.0 at a temperature of 20,0 °C. If the same wire has a resistance of 12.0 at 90.0 °C, what is the resistance of this wire when its temperature is –40.0 °C? Q2) A parallel-plate capacitor filled with air carries a charge Q. The battery is disconnected, and a slab of material with dielectric constant k = 2 is inserted between the plates. Which of the following statements is true?
A circular wire loop of radius r = 0.25 m and resistance R = 11.1 Ω...
A circular wire loop of radius r = 0.25 m and resistance R = 11.1 Ω rotates about a shaft through its diameter at a constant rate of f = 5.8 Hz in a uniform B = 0.49-T magnetic field directed perpendicular to the rotation axis. The plane of the loop is perpendicular to the magnetic field at time t = 0. a) Find the expression for the time-dependent magnetic flux through the loop. Φ = b) Find the value...
Consider two long wire with negligible resistance closed at one end of the resistance R (say...
Consider two long wire with negligible resistance closed at one end of the resistance R (say a light bulb), and the other end connected to a battery (DC voltage). Cross-sectional radius of each wire is in x=100 times smaller than the distance between the axes of the wires. Question: At which value of resistance R (in ohms) the resultant force of the interaction of parallel conductors disappears?
1. Outside temperature over a day can be modeled as a sinusoidal function. Suppose you know...
1. Outside temperature over a day can be modeled as a sinusoidal function. Suppose you know the high temperature of 65 degrees occurs at 4 PM and the average temperature for the day is 60 degrees. Find the temperature, to the nearest degree, at 6 AM. ------degrees 2. Outside temperature over a day can be modeled as a sinusoidal function. Suppose you know the temperature varies between 62 and 88 degrees during the day and the average daily temperature first...
In a machine that temperature changes from 20 ∘C∘C up to 120 ∘C∘C a tungsten wire...
In a machine that temperature changes from 20 ∘C∘C up to 120 ∘C∘C a tungsten wire filament 15.0 cmcm  long with a diameter of 1.30 mmmm  will be used. The wire will carry  14.0 AA   at all temperatures ( Resistivity of tungsten at 20 ∘C∘C is 5.25×10−8Ω⋅m5.25×10−8Ω⋅m , the temperature coefficient of resistivity at 20 ∘C∘C is 0.0045 ∘C−1∘C−1 ) Calculate the maximum electric field in this filament? Calculate the resistance of the filament  with that field? Calculate the maximum potential drop over the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT