TaskBegin by making a copy of your program from the Toleranc

Task:Begin by making a copy of your program from the \"Tolerance counts\" assignment, giving a different name to the copy. Remove the for loop, but keep the parts of the script before and after the loop.

Instead of the for loop, create a logical array indicating which elements of your weights array are less than the minimum allowable weight. You may create this logical array by comparing your weights array to the minimum weight; see Challenge Activity 5.9.2 (Links to an external site.) for a similar example.

In a similar fashion, create another logical array indicating which weights were greater than the maximum. Note:

Because you don\'t care about the weights of the overweight items, only how many there are, you do not need to index weights with the logical arrays.

To count the number of underweight/overweight items, you need to count the number of 1s in each of these logical arrays. In a logical array, the matching (true) elements count as 1, and the others (false) count as 0. Therefore, summing the elements (adding them up) using the MATLAB built-in function sum gives the number of matching weights. For example:

numOverweight = sum(overweight); % but using the variable names you chose
(and a similar line for the underweight items). After computing the number of under- and over-weight items, the rest of your program should remain the same as in week 7: compute the percentages and print messages to the command window.

Instructors suggestion:
The for loop will be replaced by four lines of code:

Make a logical array of the overweight items by comparing the weights array to the maximum acceptable weight.
This is just a comparison with \">\". Since you are comparing an array, the answer will be an entire array of true-false values: true where the item was overweight, and false where it was not.
overweight = weightsArray > maximumWeight; (but using your variable names)
Calculate the number of overweight items by summing the logical array (the line of example code in the assignment). This treats \"true\" as 1 and \"false\" as 0 and adds up the numbers, so gives you the number of \"true\"s.
Make a logical array of the underweight items by comparing the weights array to the minimum acceptable weight.
Calculate the number of overweight items by summing the second logical array.

For more about making and using logical arrays, you might review sections 5.9 and 5.5 of the ZyBook. Steps 1 and 3 are similar to Challenge 5.9.2.

.......

I have no idea , especially the true and false part.... can I get at least a hint.

MATLAB R2016a - academic use HOME PLOTS EDITOR PUBLISH VEW Search Documentation Find Files comment 963y Go To New Open Save Breakpoints Run Run and Advance Advance Run and Print Find Indent Time FILE Editor -CAUsers owner Downloads)c968aa9e871d1ea21ead90e38d2b19b341e8e02b772a0250ed5d237099b5d578.m i Logistic-comparison. x USDA x euclidplot.m X Tolerance reise m c968aa9e871d1ea21ead90e38d2b1963-41 e8e02b772a0250ed5d237099b5d578.m X+ 17-nominalWcighta-.13: 18- tolerance=0.25; 19minWeight- nominalWeights-tolerance: 20maxweight- nominalWeighte+tolerance: numUnder-0 23 24-weighte- xleread (\'Week7weighte.xlex\',\"A1:A240) 25numWeights length (weights) 26 27-1 for index- 1: numweight 28 29 30 weight- weighte (index) if weight(minWeight ; numUnder-numUnder+1 ; elscif weight>maxWeight: numover= numover+1; end Command Window Acadeic License 52 -Ready 1 Col 1 Ln 2:51 PM 10/20/2016 1 4: A

Solution

Ass per my understanding of the question, what you need is as below-

Make a logical array of the overweight items by comparing the weights array to the maximum acceptable weight :-

1) Create an array which can have value 1 to indicate overwight item and 0 to indicate non-over weight item.

2) Compare the weights array elements with the maxWeight and if array element at that index > maxWeight then fill 1(true) in that same index of the logical array else 0 (false)

3) Now add all elements of logical array to find the total number of overweight items.

same proceddure can be followed for underWeight items.

Please let me know if I misunderstood the question so that I can give more clear answer.

Task:Begin by making a copy of your program from the \
Task:Begin by making a copy of your program from the \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site