User Tools

Site Tools


faq

This is an old revision of the document!


Frequently Asked Questions

FAQs for Assignment 4

I have trouble solving Question 5. Could you give us more hints?

There are a few ways to write this program. I assume you have no problem reading the input file into a matrix. One way to write the rest of the program is to use a loop to go through all the rows in the matrix. In each pass of the loop, you take the information in one row of the matrix (which contains a person's height in inches and weight in pounds), call the IPtoCK function to convert these two numbers into cm and kg, calculate the person's BMI based on the converted cm and kg, and then determine this person's BMI category and output a line in the output file (which shows this person's height in cm, weight in kg, BMI value and BMI category).

=== The first question asks us to write a function that takes a scalar input argument. In the second question, we are asked to use this function. However, in the second question we need to check 50 numbers. Can we change our answer to the first question so that it can take a vector as an input? ===

No, you cannot change your function for the first question in order to solve the second question. Your program for the second question has to call the function that only takes a scalar as the input argument. This should easily done by using a loop.

FAQs for Assignment 3

I am unable to save a MATLAB script file on my computer. When I tried to save it, it is saved at the drive at York. Can I submit the files as Notepad files?

A couple of ways to solve this problem:

1. In the Editor window of MATLAB, save the file to your local disk C by selecting “Save as” from the File menu, and then in the pop-up window clicking on small down-pointing arrow beside the “Save in: ” slot and choosing “Local disk (C: on ….)”.

2. Copy and paste each program into Nodepad and save each program as a .txt file and then change the extension of the file name to from .txt to .m . Changing the file name can be done by right-clicking on the file name (in the folder that contains the file) and selecting “Rename”. If you are not able to change the file name, submitting the files using the .txt extension is ok. That is, the file names can be a3q1.txt, a3q2.txt ….

I am having trouble figuring out how to find the maximum value for question 2, could you give some tips?

Look at Exercises 1 and 2 in the lecture notes on Feb 3rd. They both find the biggest number, but from smaller scales of vectors. Look at the solution to Exercise 2, and extend it to find the biggest number from a vector of 4 values, and then 5 values. Hope you see the repetitions and use a loop to implement it.

For Part c) of Question 4, how can I take the dates in which the temperature in Anchorage was higher than the on in New York?

You need to put the dates one by one into a vector during the loop. After the loop you just need to print out the vector. See the solution to Exercise 7 in Feb 10th lecture notes. In that solution, a vector “identified_Participants” is created with the loop. That is, whenever a condition in the if statement is satisfied, an element of this vector is added. The trick is in how keep track of the number of elements in this vector. In the solution to Exercise 7, variable number_of_OK is used for such a purpose.

FAQs for Assignment 2

For Question 6, when I entered the command to add the Science mark as the last column in the matrix, the matrix was displayed as follows:

1.0e+003 *

Columns 1 through 5
      2.3450    0.0720    0.0800    0.0900    0.0820
  1.2340    0.0960    0.0820    0.0860    0.0880
  5.4320    0.0830    0.0860    0.0790    0.0780
  3.4560    0.0680    0.0760    0.0800    0.0900
  6.5430    0.0900    0.0850    0.0950    0.0670
  7.6540    0.0770    0.0680    0.0700    0.0690
  4.5670    0.0820    0.0830    0.0660    0.0790
Column 6
      0.0760
  0.0890
  0.0845
  0.0720
  0.0875
  0.0725
  0.0825

This is strange. Did I do anything wrong?

No, nothing is wrong. The display is fine. The values are displayed in the scientific notation. “1.0e+003 *” means all the values (in the matrix displayed below) will be multiplied by 10 to the power of 3. See slide 22 of January 27th slides. We didn't get the chance to talk about it in class. But everything was fine in your output display.

FAQs for Assignment 1

What does the exclamation marks (!) in the first question mean?

n! means the factorial of n. See http://en.wikipedia.org/wiki/Factorial for the definition of factorial. Note that MATLAB has a built-in function factorial(x) to calculate the factorial of x. It was listed in the lecture notes on January 6.

Do I need to put the output of the programs in the a1.txt file?

No, you only need to put the programs in the a1.txt file. There is no need to put the output of your programs in the file.

faq.1300399302.txt.gz · Last modified: 2011/03/17 22:01 by aan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki