Remember that the fwc function is vectorized so it

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ction is vectorized, so it can handle two T and V vectors: FWC.m function [W] = FWC(T,V) %FWC computes windchill in Fahrenheit % expects temp in T and velocity in V W = 35.74 + 0.6215*T - 35.75*V.^0.16 +.4275.*T.*V.^0.16; %fprintf('The windchill is %8.2fF\n',W); end So, instead we can build this script: % create vector of all temperatures T = 40:-5:-45; %create vector of all wind speeds V = 5:5:60; % find how many temps and how many velocities Tlen = length(T); Vlen = length(V); % create a matrix of temperatures where each row of % temperatures is repeated Vlen times Tmat = repmat(T,Vlen,1); % flip the velocities to a column and create a matrix % of velocities where each column of V is repeated Tlen times Vmat = repmat(V',1,Tlen); % use the (:) operator to convert both matrices to vectors, % send the vectors into FWC, round the results and reshape the answers % into a Vlen x Tlen table or matrix. theTable = reshape(round(F...
View Full Document

This document was uploaded on 03/16/2014 for the course CS 106 at Mt. Holyoke.

Ask a homework question - tutors are online