Question

In: Computer Science

I need to write a MATLAB code for this question, but I couldn't figure how to...

I need to write a MATLAB code for this question, but I couldn't figure how to do it.

7. Engineers often have to convert from one unit of measurement to another; this can be tricky sometimes. You need to think through the process carefully. For example, convert 5 acres to hectares, given that an acre is 4840 square yards, a yard is 36 inches, an inch is 2.54 cm, and a hectare is 10000 m2.

Solutions

Expert Solution

First developing a formula to convert acres to hectares using the conversions given in the question.

The conversions given are:

1 acre = 4840 square yards

1 yard = 36 inches

1 inch = 2.54 cm

1 hectare = 10000 m2.

1 square yard = 362 inches2

= (36 x 2.54)2 cm2

Therefore,

1 acre = 4840 x (36 x 2.54)2 cm2

= 0.4047 x 108 cm2

= 0.4047 x 108 x 10-4 m2 (1 cm2 = 10-4 m2)

= 0.4047 x 104 m2

= 0.4047 hectares

So,

1 acre = 0.4047 hectares

Code:

y = AcresToHectares(5);

function hectares = AcresToHectares(acres)              
    hectares = 0.4047 * acres;
    fprintf('%d acres converted into hectares is: %.3f hectares',acres,hectares);
end

Code screenshot:

Output:


Related Solutions

Write the MATLAB code to Create a new figure. Define a theta array such that ?...
Write the MATLAB code to Create a new figure. Define a theta array such that ? 2 ≤ ? ≤ 9? 2 with increment of ? 10 ; Create a sixmember array of ones called r. Create a new polar plot of ? versus r
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar...
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar to a sine or cosine graph or similar to electrocardiograms (EKG/ECG) graph. Please I'd appreciate it. All love. Thanks :) In elementary quantum mechanics, the square well is used to model the behavior of a bound particle, in which one or more forces (external potentials, interaction with other particles, etc) prevent or restrict its ability to move about. We have seen in class that...
i need matlab code of heat equation in 1D with convection ?
i need matlab code of heat equation in 1D with convection ?
I'm new in MATLAB and I have to write a code in MATLAB which converts a...
I'm new in MATLAB and I have to write a code in MATLAB which converts a number from one base to another without using base2base, etc
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications: Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4. The plot should have: (1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin...
pls, I need Matlab code for, OFDM modulation (Matlab demo by at least 4 carriers)
pls, I need Matlab code for, OFDM modulation (Matlab demo by at least 4 carriers)
Hello, I need the Matlab code of the Fourier Transform without using the Matlab functions fft...
Hello, I need the Matlab code of the Fourier Transform without using the Matlab functions fft and dft. Applied to discrete signals. If you can with an example.Thank you!!
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast...
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast Its urgent The code must run on any matrix given It should be a generic code Dont answer any wrong code or else i will badly dislike
Matlab code problems I have to write a code using functions to find out if a...
Matlab code problems I have to write a code using functions to find out if a year is a leap year. I'm on the write track i feel like but I keep getting an error message and matlab isnt helping to troubleshoot. The issue is on line 30. Here is my code: function project_7_mfp() %   PROJECT_7_ABC   project_7_abc() creates a function that prompts the user %   enter a year after 1582 It then determines if it is a leap year %...
Chemistry question: We did an experiment in lab and I need to figure out how to...
Chemistry question: We did an experiment in lab and I need to figure out how to A) calculate the mols of NaOH used in titration B) calculate mols HCl in titration C) calculate mols of CaCO3 reacted D) calculate grams of CaCO3 reacted E) calculate percentage of CaCO3 in TUMS. I really need to see all the steps that way I can understand what is going on. We did four titrations with the following information 38 mL HCl, 19.913 g...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT