Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Company manufactors 2. A company manufactures cylinders from different materials

ID: 3701520 • Letter: C

Question

Company manufactors

2. A company manufactures cylinders from different materials for industrial use. Information on them is stored in a data structure in a program. The variable cyls is a structure with fields code, dimensions, and weight. The dimensions field is a structure itself consisting of fields rad and height for the radius and height of each cylinder. Wrie a function that stores this table in a structure variable named cyls. This script gets the code of a cylinder from a user and calculates its volume. It will then report volume and weight of the cylinder.

Explanation / Answer

function res=regression(x,y,r,d,lt)
n=len(x);
Z=[];
for i=d:-1:0
Z=[Z x.^i]; % Forming the matrix Z
end
  
a(1)=zeros(d+1,1); % Since indexing in matlab starts at 1 , a(1)
for i=1:lt % stores the vector of zeros initially
temp=0;
for j=1:n
temp=temp+(y(j)-(Z(j,:)*a(i)))*(Z(j,:)');
end
temp=temp.*r;
a(i+1)=a(i)+temp;
end

  
res=a(lt+1); % After lt number of iterations the resulting vector a
% is stored in res and returned
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote