Given a temperature, return windchill as a vector.
5 views (last 30 days)
Show older comments
On a windy day, a temperature of 15 degrees may feel colder, perhaps 7 degrees. The formula below calculates the "wind chill," indicating the temperature that is felt based on the actual temperature (T, in Fahrenheit) and wind speed (W, in miles per hour):
windChill = 35.7 + 0.6T - 35.7W^0.16 + 0.43TW^0.16 In a previous problem you wrote a function to return the wind chill for a single temperature T and wind speed W. In this problem the function is given a single temperature T but a vector of wind speeds WV; your job is to return a vector of wind chills, one for each temperature and wind speed pair. For example, if T is 32 and WV is [1:5], then the function returns the vector [32.9600, 30.3867, 28.7437, 27.5116, 26.5161].
Here is the code given
function windChills = ComputeWindChills(T, WV) windChills = ... ; end
finish the code.
0 Comments
Answers (2)
Image Analyst
on 7 Nov 2015
It seems like the question told you the answer, except maybe to put in a few operators like * and . (dot) to fix the syntax.
windChill = 35.7 + 0.6T - 35.7W^0.16 + 0.43TW^0.16
First of all, you'll need to change windChill to windChills to give it the desired name. Then, look up "times, .* - Element-wise multiplication" in the help. You'll also need size() or length() to verify that the size and shape of T and W are the correct and allowable. Inserting 7 characters into the above line of code will produce the correct syntax and correct answer (except for input validation like I mentioned, but you may not need to do that because the problem said you can assume a scalar and a vector are passed in).
2 Comments
Image Analyst
on 7 Nov 2015
Edited: Image Analyst
on 22 Jan 2021
You didn't look up "times, .* - Element-wise multiplication" like I suggested. If you had, you would have known to use .^ instead of ^.
function windChills = ComputeWindChills(T, WV, W)
windChills = 35.7 + 0.6 * T - 35.7 * W .^ 0.16 + 0.43 * T .* W .^ 0.16
end
If T and W are vectors, then windChill will be a vector. But the last term there is (0.43 * T) .* (W.^0.16), not (0.43 * T .* W) .^ 0.16 so make sure you use whichever one you're supposed to.
In your function you don't pass in W, you pass in WV. I don't know what WV is. You don't show it in your formula. What is the use of WV?
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!