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

You may load the data into MATLAB with the command load toxic.csv. The data will

ID: 3599667 • Letter: Y

Question

You may load the data into MATLAB with the command load toxic.csv. The data will then be in an array called toxic. The column information represents:

Column 1: Year AD

Column 2: Cadmium (nanograms per gram)

Column 3: Lead (nanograms per gram)

Column 4: Thallium (nanograms per gram)

ALLOWED SYNTAX: Complete the following (1) WITHthe use of for loopsand conditional blocks[i.e. if-elseif...else-end]; (2) you may NOT use any syntax requiring the dot operator; (3) you may use relational operators on scalars but you may NOTuse them on arrays. (Relational operatorsinclude: <, >, <=, >=, ==, ~=) (4) You may reuse theyears that were found using the find function in Section 1.

1.How many years during the period of this data set have a lead concentration greater than 0.2 ng/g?

2.For what percentage of the years during the 1800s (1800-1899) is the lead concentration greater than 0.01 ng/g?

3.What is the most recent year during which lead is greater than 100times the concentration of cadmium?Whatis the concentration of Pb that year?

4.For which year during the 1900s (1900-1999) did cadmium contribute its largest fraction to the total heavy metal concentration (i.e., year with largest Cd/(Pb+Cd+Th))?What is that value?(hint: help max)

5.[Up to 2pt bonus]During which decades (i.e, 1900-1909, 1910-1919, etc.) of the 1900s did lead concentration exceed 0.3 (ng/g)?

Explanation / Answer

%without data it is hard to find out errors, so if any answer is wrong, mention it in the comments

d=load('toxic.csv');
[r,c]=size(d);
%1
a=0;
for i=1:r
if d(i,3)>.2
a=a+1;%a holds answer to first question
end
end
%2
y=0;
for i=1:r
if d(i,1)>=1800 && d(i,1)<=1899
if d(i,3)>.01
y=y+1;
end
end
end
%y is the percentage(since there are 100 years spanned in 1800 to 1899)
%3
yLead=0;%these variables hold answers for 3rd part
year=0;
for i=r:-1:1
if d(i,3)>100*d(i,2)
yLead=d(i,3);
year=d(i,1);
break;
end
end
%4
m=0;
yCd=0;%this variable holds the year for which cntribution is highest
for i=1:r
if d(i,1)>=1900 && d(i,1)<=1999
conc=d(i,2)/(d(i,2)+d(i,3)+d(i,2));
if conc>m
yCd=d(i,1);
m=conc;
  
end
end
end
%5
dec=zeros(1,10);
k=0;
for i=1:r
if d(i,1)>=1900 && d(i,1)<=1999
  
if d(i,3)>.3
dec(floor(k/10)+1)=1;
end
k=k+1;
end
end
decades=zeros(10,2);%this array holds the deacdes in 2 columns
l=1;
for i=1:10
if dec(i)==1
decades(l,1)=1900*i+10*i;
decades(l,2)=decades(l,1)+9;
l=l+1;
end
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