This is a Matlab question. \"store the data from the given table into a structur
ID: 3769091 • Letter: T
Question
This is a Matlab question.
"store the data from the given table into a structure array. Use the array to find:
a) the element with the maximum density.
b) the element with the maximum atomic weight
I have already completed the structure. It is as follows:
data = struct('Metal',{'Aluminum','Copper','Iron','Molybdenum','Cobalt','Vanadium'},...
'Symbol',{'Al','Cu','Fe','Mo','Co','V'},'Atomic_Number',{13,29,26,42,27,23},...
'Atomic_Weight',{26.98,63.55,55.85,95.94,58.93,50.94},...
'Density',{2.71,8.94,7.87,10.22,8.9,6.0},...
'Crystal_Structure',{'FCC','FCC','BCC','BCC','HCP','BCC'})
how to access the element with the maximum density, and the element with the maximum atomic weight? This is what I have not been able to accomplish.
Will rate lifesaver.
Explanation / Answer
Ok. Here is the code for you... If you have any further queries, just get back to me....
data = struct('Metal',{'Aluminum','Copper','Iron','Molybdenum','Cobalt','Vanadium'},...
'Symbol',{'Al','Cu','Fe','Mo','Co','V'},'Atomic_Number',{13,29,26,42,27,23},...
'Atomic_Weight',{26.98,63.55,55.85,95.94,58.93,50.94},...
'Density',{2.71,8.94,7.87,10.22,8.9,6.0},...
'Crystal_Structure',{'FCC','FCC','BCC','BCC','HCP','BCC'})
max = 1;
for i = 1:6
if(data(i).Density > data(max).Density)
max = i;
end
end
format = 'The element with maximum density is: %.2f.';
sprintf(format, data(max).Density)
max = 1;
for i = 1:6
if(data(i).Atomic_Weight > data(max).Atomic_Weight)
max = i;
end
end
format = 'The element with maximum atomic weight is: %.2f.';
sprintf(format, data(max).Atomic_Weight)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.