Write a matlab function function [ area ] = myCalculateArea( X, res ) a. INPUTS:
ID: 3694792 • Letter: W
Question
Write a matlab function
function [ area ] = myCalculateArea( X, res )
a. INPUTS: i. A 2D matrix X ii. A resolution in mm per pixel. E.g., if res is 0.4, each pixel is 0.4mm per side.
b. FUNCTIONALITY: i. This function simply multiplies the number of non-zero values in X by the resolution to calculate the total area of the
c. OUTPUTS: i. area: the total area of the bone pixels in X, in units of mm^2.
TEST CASE: >> A = [176.2360 171.0640 115.8960 162.4440;207.2680 179.6840 0 0; 233.1280 190.0280 145.2040 146.9280; 248.6440 177.9600 181.4080 164.1680];
>> myCalculateArea(A, 0.4)
ans = 2.2400
Explanation / Answer
function [ area ] = myCalculateArea( X, res )
area = nnz(X)*res*res;
end
A = [176.2360 171.0640 115.8960 162.4440;207.2680 179.6840 0 0; 233.1280 190.0280 145.2040 146.9280; 248.6440 177.9600 181.4080 164.1680];
area=myCalculateArea(A, 0.4);
disp(area);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.