bit of a random but i just finshed my coding assignemnt

Discussion in 'Lounge & Gossip' started by Naj_Ej, Friday 11th Dec, 2009.

  1. Naj_Ej Club Veteran ★ ★ ★ ★ ★

    just finhed my coding assigment start at this afternoon at 2:30 o so then stoped 7;30 till about 11 then off i went again and finshed at 5:10am lol hers my assingment will mean a load of shit to but meh:Tongue: thank god i only had it for 1 semsta!


    Quiz 01


    User ID: NS376 Attempt: 4 / Unlimited Out of: 10


    Started: December 9, 2009 2:00pm Finished: December 9, 2009 2:01pm Time spent: 1 min. 37 sec.


    Question 1 (1 point)


    An assignment statement:


    Student response: Student


    Response Answer Choices


    a. is used to describe and place a task on a specific processor.


    b. is used to give behaviours to variables.


    c. is used to permanently set the values of variables.


    d. is used to set the values of variables, which can be subsequently changed by further assignment statements.


    Question 2 (1 point)


    In programming, a function is:


    Student response: Student


    Response Answer Choices


    a. a button on the keyboard prefixed with F.


    b. a statement that allows information, such as the result of a calculation, to be displayed.


    c. a collection of statements, given a name, that can be called upon to perform specific tasks whenever needed.


    d. a program statement that operates upon a variable.


    Question 3 (1 point)


    In programming, an operator is:


    Student response: Student


    Response Answer Choices


    a. any symbol that appears in the program (e.g., +, /, *)


    b. the user


    c. the programmer


    d. the data to be operated upon


    Question 4 (1 point)


    In programming, a literal is:


    Student response: Student


    Response Answer Choices


    a. a function or statement that accepts arguments


    b. a specific value that appears directly in the program code, such as a number, letter or word.


    c. any numeric value appearing as a function argument.


    d. a named container, used for storing values while the program is running.


    Question 5 (1 point)


    The syntax of a programming language


    Student response: Student


    Response Answer Choices


    a. limits the number of functions that are available.


    b. determines how quickly a program will run.


    c. determines how easily a program can be ported to the web.


    d. describes the grammatical rules that must be followed to prepare a program.


    Question 6 (1 point)


    A program variable


    Student response: Student


    Response Answer Choices


    a. is a named container that can be used to hold values.


    b. describes a function that can be called upon to change a value.


    c. is typically used to create collections of program statements.


    d. requires arguments.


    Question 7 (1 point)


    Which of the following is not a program statement?


    Student response: Student


    Response Answer Choices


    a. b = 3;


    b. a = sqrt(b^2 + c^2);


    c. disp(a);


    d. they are all program statements.


    Question 8 (1 point)


    Functions must be supplied with the information that they operate upon. We refer to this information as the function's


    Student response: Student


    Response Answer Choices


    a. accoutrements


    b. arguments


    c. acquirements


    d. altercations


    Question 9 (1 point)


    A dry run


    Student response: Student


    Response Answer Choices


    a. is the step-by-step running of a program on paper.


    b. is the step-by-step recording of program statements.


    c. is a process to enable the program statements to be joined to one another.


    d. is used after a program has been debugged.


    Question 10 (1 point)


    Which of the following phrases describing a valid program statement is always true?


    Student response: Student


    Response Answer Choices


    a. is an equation balancing the LHS and RHS of the "=".


    b. is a rule definition or axiom.


    c. is in a syntax that is understood by the language.


    d. is always correct.


    Total score: 9 / 10 = 90.0%


    Home quiz 2


    Quiz 02


    User ID: NS376 Attempt: 5 / Unlimited Out of: 10


    Started: December 9, 2009 6:21pm Finished: December 9, 2009 6:24pm Time spent: 2 min. 12 sec.


    Question 1 (1 point)


    Which of the following is a property of scalar variables?


    Student response: Student


    Response Answer Choices


    a. they are singular.


    b. they are multiplicitous.


    c. their values, once set, cannot be changed.


    d. they have an implicit "direction".


    Question 2 (1 point)


    Which of the following is a defining property of vector variables?


    Student response: Student


    Response Answer Choices


    a. they are singular.


    b. they are multplicitous.


    c. once set, their values cannot be changed.


    d. they have no implicit "direction".


    Question 3 (1 point)


    Which of the following is a defining feature of matrix variables?


    Student response: Student


    Response Answer Choices


    a. they are singular.


    b. once set, they cannot be changed.


    c. they are multidimensional.


    d. they are often used to hold audio.


    Question 4 (1 point)


    Which of the following is an example of a scalar variable?


    Student response: Student


    Response Answer Choices


    a. a grid of quiz grades, with axes for student number and week number.


    b. a computer game high score table.


    c. the current balance of your bank account.


    d. a sound wave.


    Question 5 (1 point)


    Which of the following is an example of a vector variable?


    Student response: Student


    Response Answer Choices


    a. the current annual salary of the Prime Minister.


    b. the average student grade in Coding Concepts' "Homework Quiz 1".


    c. a list of grades for Coding Concepts' "Homework Quiz 1".


    d. all of the above.


    Question 6 (1 point)


    Which of the following is an example of a matrix variable?


    Student response: Student


    Response Answer Choices


    a. volume of water found on Mars.


    b. heat map of the surface of Mars.


    c. list of distances from each planet in our solar system to Mars.


    d. all of the above.


    Question 7 (1 point)


    A colour bitmap typically consists of how many matrices?


    Student response: Student


    Response Answer Choices


    a. 1


    b. 2


    c. 3


    d. 4


    Question 8 (1 point)


    A single location in a vector or matrix is generally referred to as what?


    Student response: Student


    Response Answer Choices


    a. pixel


    b. voxel


    c. texel


    d. element


    Question 9 (1 point)


    Why is an IR image shown as shades of blue and red?


    Student response: Student


    Response Answer Choices


    a. the imaging device captures it that way.


    b. because IR light is not part of the visible spectrum.


    c. because it looks nice.


    d. because it only uses the R and B matrices of the the RGB system.


    Question 10 (1 point)


    If a scalar variable storing an integer (i.e., a whole number) requires 4 bytes of memory, how much memory would be required to store a 5x5 matrix of integers?


    Student response: Student


    Response Answer Choices


    a. 20


    b. 25


    c. 100


    d. it depends on the precise values stored at each coordinate.


    Total score: 8 / 10 = 80.0%


    Homework Quiz2


    Quiz 03


    User ID: NS376 Attempt: 1 / Unlimited Out of: 10


    Started: December 9, 2009 6:24pm Finished: December 9, 2009 6:42pm Time spent: 18 min. 7 sec.


    Question 1 (1 point)


    The two main forms of selection (conditional logic) available in Matlab are?


    Student response: Student


    Response Answer Choices


    a. if and when


    b. if and switch


    c. if and else


    d. switch and case


    Question 2 (1 point)


    The expression between the round brackets in an if construct is called what?


    Student response: Student


    Response Answer Choices


    a. evaluation


    b. boolean


    c. condition


    d. iterator


    Question 3 (1 point)


    In what circumstances is an "else" clause run?


    Student response: Student


    Response Answer Choices


    a. when none of the prior conditions evaluated to true


    b. when none of the prior conditions evaluated to false


    c. when all the prior conditions were syntactically invalid


    d. when a vector rather than a scalar was used as input


    Question 4 (1 point)


    The corresponding keyword to switch, used to denote particular circumstances is what?


    Student response: Student


    Response Answer Choices


    a. else


    b. value


    c. case


    d. item


    Question 5 (1 point)


    Using the code fragment


    if(a< B)


    disp('hi');


    end


    and assuming that b is 10, what value of a will cause 'hi' to be displayed? Tick all that apply.


    Student response: Student


    Response Answer Choices


    a. 8


    b. 9


    c. 10


    d. 11


    Question 6 (1 point)


    In an if construction, why do we indent the "body" of code that is selectively executed?


    Student response: Student


    Response Answer Choices


    a. So that the programming language knows that this code is predicated on the conditions being satisfied.


    b. So that the programming language selects the correct path through the code.


    c. So that the program is easier to read and maintain.


    d. So that the program runs more quickly.


    Question 7 (1 point)


    Which of the following is not an example of selection?


    Student response: Student


    Response Answer Choices


    a. to make tea for a friend, add teabag to boiling water, ask if they want milk and sugar, then add accordingly.


    b. cross the road only if there are no cars coming.


    c. if you are hungry, then eat.


    d. repeatedly read lecture notes and taking homework quiz until you score 8 or above.


    Question 8 (1 point)


    Boolean expressions:


    Student response: Student


    Response Answer Choices


    a. produce a binary result (true/false)


    b. may be used to control program flow


    c. can be formulated using relational and logical operators


    d. all of the above


    Question 9 (1 point)


    Not an example of a relational operator:


    Student response: Student


    Response Answer Choices


    a. ==


    b. <


    c. ~=


    d. /


    Question 10 (1 point)


    An example of a logic operator:


    Student response: Student


    Response Answer Choices


    a. <


    b. ~=


    c. &


    d. =


    Total score: 9 / 10 = 90.0%


    Homework Quiz 4


    Quiz 04


    User ID: NS376 Attempt: 2 / Unlimited Out of: 10


    Started: December 9, 2009 9:28pm Finished: December 9, 2009 9:29pm Time spent: 1 min. 28 sec.


    Question 1 (1 point)


    The three procedural programming constructs are (tick all that apply):


    Student response: Student


    Response Answer Choices


    a. iteration


    b. condition


    c. selection


    d. sequence


    Question 2 (1 point)


    The technical term "iteration" has a similar meaning to the word:


    Student response: Student


    Response Answer Choices


    a. branch


    b. choice


    c. divert


    d. repeat


    Question 3 (1 point)


    In Matlab, the two main keywords for performing iteration are (tick two):


    Student response: Student


    Response Answer Choices


    a. repeat


    b. loop


    c. for


    d. while


    Question 4 (1 point)


    The iteration of a while code block terminates when?


    Student response: Student


    Response Answer Choices


    a. When a condition is satisfied


    b. When a condition is no longer satisfied


    c. When the requisite number of iterations have been performed


    d. When the user requests that the iteration finish


    Question 5 (1 point)


    A typical for loop definition looks like this:


    for i=5:10


    % Action


    end


    What is i?


    Student response: Student


    Response Answer Choices


    a. An image


    b. A function


    c. A variable used as a counter


    d. A literal


    Question 6 (1 point)


    A typical for loop definition contains two numbers, like this:


    for i=5:10


    % Action


    end


    What is 5?


    Student response: Student


    Response Answer Choices


    a. The start value for i


    b. The end value for i


    c. A loop condition that must be satisfied


    d. A placemarker for the specific function to be applied within the loop


    Question 7 (1 point)


    If loops are nested, it means that:


    Student response: Student


    Response Answer Choices


    a. They have somewhere warm and soft to sleep


    b. They are embedded one inside another


    c. The number of iterations is known a priori


    d. They appear one after another, i.e., they are "nestled" together


    Question 8 (1 point)


    Loops may be used to step through the elements of a vector or matrix. To step through a vector, the loop counter is placed after the vector's name, between which type of brackets?


    Student response: Student


    Response Answer Choices


    a. curly


    b. square


    c. round


    d. chevrons


    Question 9 (1 point)


    Which of the following is a valid reason for using iteration?


    Student response: Student


    Response Answer Choices


    a. Our program need to decide whether to perform an action or not


    b. Our program needs to perform a number of actions in turn


    c. Our program needs to repeat an action a number of times


    d. Our program needs to perform an action only if multiple conditions are satisfied


    Question 10 (1 point)


    For a matrix of N dimensions, how many nested loops are required to ensure that all elements are individually visited?


    Student response: Student


    Response Answer Choices


    a. 1


    b. N^2


    c. N/2


    d. N


    Total score: 8 / 10 = 80.0%


    Homework quiz 5


    Quiz 05


    User ID: NS376 Attempt: 2 / Unlimited Out of: 10


    Started: December 10, 2009 12:13am Finished: December 10, 2009 12:14am Time spent: 1 min. 30 sec.


    Question 1 (1 point)


    The MIT Scratch Forever block is an example of what type of loop?


    Student response: Student


    Response Answer Choices


    a. Pre-conditioned


    b. Definite


    c. Finite


    d. Infinite


    Question 2 (1 point)


    The MIT Scratch Repeat N block, where N is a number, is an example of what type of loop?


    Student response: Student


    Response Answer Choices


    a. for


    b. while


    c. definite


    d. indefinite


    Question 3 (1 point)


    In MIT Scatch, where we see a block like:


    play sound "meow"


    what is meow?


    Student response: Student


    Response Answer Choices


    a. a function


    b. an argument


    c. a condition


    d. a selection


    Question 4 (1 point)


    The MIT Scratch block


    touching "edge"


    is an example of what?


    Student response: Student


    Response Answer Choices


    a. selection


    b. iteration


    c. condition


    d. increment


    Question 5 (1 point)


    The MIT Scratch block, shown in a green box with angled edges, saying:


    [ ] < [ ]


    is an example of what type of expression?


    Student response: Student


    Response Answer Choices


    a. arithmetic


    b. bitwise


    c. logical


    d. relational


    Question 6 (1 point)


    The MIT Scratch block:


    [ ] mod [ ]


    is used for what purpose?


    Student response: Student


    Response Answer Choices


    a. To determine if a variable has been modified


    b. To determine if one variable is divisible by another (modulus)


    c. To determine if one variable is modulated by another


    d. To determine the mode of a variable


    Question 7 (1 point)


    In MIT Scratch, mouse x and mouse y are examples of what?


    Student response: Student


    Response Answer Choices


    a. Constants


    b. Functions


    c. Vectors


    d. Variables


    Question 8 (1 point)


    In a MIT scratch program, multiple sub-programs may all be running at the same time. What is this behaviour called?


    Student response: Student


    Response Answer Choices


    a. Multiprogramming


    b. Multicomputing


    c. Multithreading


    d. Time Turning


    Question 9 (1 point)


    In MIT Scratch, the maths function block supports the following operations (select all that apply):


    Student response: Student


    Response Answer Choices


    a. sqrt


    b. fft


    c. log


    d. sin


    Question 10 (1 point)


    In MIT Scratch, an if-elseif-else is implemented how:


    Student response: Student


    Response Answer Choices


    a. Choosing the if-elseif-else block


    b. Placing an if block inside a loop block


    c. Placing an if-else block inside an if block


    d. Placing an if-else block inside another if-else block


    Total score: 9 / 10 = 90.0%


    Homework Quiz 6


    Quiz 06


    User ID: NS376 Attempt: 1 / Unlimited Out of: 10


    Started: December 10, 2009 12:15am Finished: December 10, 2009 12:33am Time spent: 18 min. 31 sec.


    Question 1 (1 point)


    Where a vector is to be used to hold a sound, what are the individual values in the vector called?


    Student response: Student


    Response Answer Choices


    a. samples


    b. channels


    c. frequencies


    d. wavelengths


    Question 2 (1 point)


    The length of a sound, in seconds, can be calculated by dividing the number of samples by what?


    Student response: Student


    Response Answer Choices


    a. the amplitude


    b. the resolution


    c. the frequency


    d. the sampling rate


    Question 3 (1 point)


    A programmer wrote the add echo routine shown below to add a 2 sec echo. What is the sampling rate?


    f=v;


    for i=1:length(v)-22050


    f(i+22020) = ( f(i+22050) + f(i) ) / 2;


    end


    Student response: Student


    Response Answer Choices


    a. 11025


    b. 22050


    c. 44100


    d. 88200


    Question 4 (1 point)


    What does the function ABS() do?


    Student response: Student


    Response Answer Choices


    a. enables values to be absent.


    b. remove the sign from a value.


    c. enables us to use an "all binary sound".


    d. extracts the imaginary component of a complex number.


    Question 5 (1 point)


    How many values are in the array e after the following line of code has been run:


    e = [1:1:10];


    Student response: Student


    Response Answer Choices


    a. 1


    b. 10


    c. 100


    d. 0


    Question 6 (1 point)


    What is the effect of the following piece of code?


    for i=1:length(v)


    if(mod(i,2)==0)


    w(i) = 0;


    else


    w(i) = v(i);


    end


    end


    Student response: Student


    Response Answer Choices


    a. Copy every even value from vector v into vector w, setting odd values to 0.


    b. Copy every odd value from vector v into vector w, setting even values to 0.


    c. Copy every odd index from vector v into vector w, setting even indices to 0.


    d. Copy every even index from vector v into vector w, setting odd indices to 0.


    Question 7 (1 point)


    What would a fade-out envelope look like as a vector?


    Student response: Student


    Response Answer Choices


    a. values would increase from index 1 to index N


    b. indices would increase from value 1 to value N


    c. values would decrease from index 1 to index N


    d. indices would decrease from value 1 to value N


    Question 8 (1 point)


    If you played a 1 second fade-in envelope through a speaker, what would happen?


    Student response: Student


    Response Answer Choices


    a. Nothing, as there are no samples.


    b. The speaker would play a distorted noise.


    c. The speaker cone would move outwards over a 1 second duration.


    d. Matlab would refuse to play it, because it is an envelope and not a sound.


    Question 9 (1 point)


    What does the Matlab command "hold on" do?


    Student response: Student


    Response Answer Choices


    a. it causes the program to pause.


    b. it keeps the specified variable in memory.


    c. it retrieves a cleared variable.


    d. it stops a line plot from automatically clearing when a second series is added.


    Question 10 (1 point)


    Given a vector v of sample rate 22050, what sample rate will the vector w have after the following code is run:


    w = v(1:end/2);


    Student response: Student


    Response Answer Choices


    a. 44100


    b. 22050


    c. 11025


    d. impossible to say


    Total score: 8 / 10 = 80.0%


    Tutorial 1 Exercise 1


    Aim of Exercise


    The purpose of exercise 1 is to be able know what the third side of the triangle is by using Pythagoras system. 2 values are on triangle, b and c are given from the user, and the third side of the triangle (a) is to be worked out without using the theory


    Code


    % Title: Tut1ex1.m


    % Description: sequence code


    % Author:0803939


    % Last Edit: 24/ September 2009


    b=input('Enter value for b: ');


    c=input('Enter value for c: ');


    a=sqrt(b^2+c^2);


    disp (a)


    Code description


    The input() function allows users to supply values for variables B and C. Then values B and C are squared using the power operator^ then added combined together using the addition operator+. The answer is then square rooted using sqrt function, then that answer is stored in variable a. Value a is then displayed from the user using the disp() function.


    Tutorial 1 exercise 2


    Aim of Exercise


    Exercise 2 shows you how to calculate the disk space by calculating the, length of seconds x the sample rate x the resolution x the number. Values of length t, sample rate, s, resolution, r, c, are provided from the user and size of disk b, will be the answer after the calculation is executed.


    Code


    Title: Tut1.ex2.m


    % Description:disk size


    % Author: 0803939/2


    % Last Edit: 24/september 2009


    t=input('length seconds: ');


    s=input('sample rate: ');


    r=input('resolution: ');


    c=input('amount of channels : ');


    b=t*s*r*c2d;


    disp ( B)


    Code description


    The input function allows the user to supply values for variables t , s , r ,c. Then these values are simply multiplied together using the multiply function*. That answers is then stored in variable b, the value of b is the displayed using the disp function.


    Tutorial 1 exercise 3


    Aim of Exercise


    This exercises aim is to be able to calculate the object kinetic energy that is relative to the velocity by calculating, weight x velocity squared then divided by 2. Values m (weight) and velocity (v) are given by the user and the objects kinetic energy, k will then be answered after the calculation has been executed.


    Code


    % Title: Tut1ex3.m


    % Description:Aghast:bject,velocity calculation


    % Author:0803939/2


    % Last Edit:24/september/2009


    m=input('weight: ');


    v=input('velocity: ');


    k=(m*v^2)/2;


    disp (k);


    Code description


    The input function allows the user to supply values for variables m , v , the values of the variables are multiplied using the multiply operator*, then squared using the power operator^. Then divided by 2 then stored in variable k. Then displayed by the disp function.


    Tutorial 1 exercise 4


    Aim of Exercise


    Exercise for the aim is to be able to implement the common formula in computer science also know as Amdahl’s law. It signifies how truly effective the multi processor computer system is by evaluating how often processors can be used by programs.


    This formula allow the speed up that can be achieved then will be calculated by 1 the proportion of the program that will be exploit the processors, + the proportion of a program that can exploits the processors. 1 value of the proportion of a program that can be exploited is the additional processors , p , and the number of processors , n , are given by the user and then maximum speed up ,s, will answer the calculation.


    Code


    % Title: Tut1ex4.m


    % Description: speed up calculation


    % Author:0803939/2


    % Last Edit:24/september/2009


    p=input('the proportion that shows the programs exploit ');


    n=input('number of process');


    s=1/((1-p)+(p/n));


    disp (s);


    code description


    The input function allows the user to supply values for variables p, n. The first calculated value is p, using the subtraction operation-, the second calculated value is p/n using the division operator. The answer to these two calculation are then added using the addition operator+, then divided by 1 using the division operator , the answer is then stored in variable s. The s value is displayed using the disp function.


    Tutorial 1 exercise 5


    Aim of Exercise


    The aim of this exercise is to be able to create a computer program to perform a compound interest calculation. The values of the principles amount 1 annul nominal interest rate/ numbers of times have the interest compound per year, number of times the interest is compounded per year*numbers of years.


    Value of principles p , annual nominal interest rate r , number of the times the interest is the compound per year , n , and number of years , t , are submitted from the user and the compound interest calculation , a, will be the answer after calculation.


    Code


    % Title: Tut1ex5.m


    % Description:interest calculation


    % Author:0803939/2


    % Last Edit: 24/september/2009


    p=input('principle amount: ');


    r=input('annual interest rate: ');


    n=input('number of interest: ');


    t=input('number of years: ');


    a=p*(1+(r/n))^(n*t);


    disp (a)


    Code description


    The input function allows users to supply values for the following variables, p, r, n; t. Calculation 1 is 1+r/n using the addition and division operators. Calculation number 2 is n*t. The last calculation is to be answer to question number 1 to the power of the second. Equation using the power operator^. The answer is then stored in variable a, the value of a , is the displayed using the disp function.


    Tutorial 2 exercise 1


    Aim of Exercise


    The aim of this exercise is to be able to find the mean, m, median , m max, m, number , ma, min number , mi, sum , su ,size , si , mode , mo and the intensity at the position of 10,20 of the image , p , which is from the user.


    Code


    % Title: Tut2ex1.m


    % Description: the mean, median, max, min, sum, size


    % Author:0803939/2


    % Last Edit: 30/september/2009


    filename=input('enter filename: ', 's');


    i=imread(filename);


    imshow(i);


    m=mean2(i);


    disp(m)


    m=median(median(i));


    disp(m)


    m=mode(mode(double(i)));


    disp(m);


    m=max(max(i));


    disp(m);


    m=min(min(i));


    disp(m);


    m=sum(sum(i));


    disp(m);


    m=size(i);


    disp(m);


    x=input('enter x co-ordinates: ');


    y=input('enter y co-ordinates: ');


    p=i(x,y);


    disp(p);


    title('circuit board');


    axis on;


    xlabel('x position (pixels)');


    ylabel('y position (pixels)');


    colorbar;


    disp (p);


    Code description


    The input function alloys the user to enter an image to open. With this image , the mean , median, max number, min number , sum size , and mode of the image is calculated using. Mean2() , median(median()), max (max()), min(min()) sum(sum()) size(size()) and the mode(mode(double())) functions.


    Then to calculate the co-ordinates 10,20 of the image. The input function will allow the user to supply the co-ordinates at which they wish to calculate the intensity of the image chosen from x and y. The calculation i(x,y) is the executed, the answers then stored in variable ,p, and the value is then displayed using disp function .


    Tutorial 2 exercise 2


    Aim of Exercise


    Exercise 2 is to annotate an image and calculate and then display the images contrast. To display the contrasts and calculation , max, (max(double(i))), a , min(min(double(i))),b needs to be executed. The answers from the calculation will be image contrast m.


    Code


    % Title: Tut2ex1.m


    % Description: the mean, median, max, min, sum, size


    % Author:0803939/2


    % Last Edit: 30/september/2009


    filename=input('enter filename: ', 's');


    i=imread(filename);


    imshow(i);


    m=mean2(i);


    disp(m)


    m=median(median(i));


    disp(m)


    m=mode(mode(double(i)));


    disp(m);


    m=max(max(i));


    disp(m);


    m=min(min(i));


    disp(m);


    m=sum(sum(i));


    disp(m);


    m=size(i);


    disp(m);


    x=input('enter x co-ordinates: ');


    y=input('enter y co-ordinates: ');


    p=i(x,y);


    disp(p);


    title('circuit board');


    axis on;


    xlabel('x position (pixels)');


    ylabel('y position (pixels)');


    colorbar;


    disp (p);


    Code description


    The input function will allow users to provide the image to be used, which is then read and stored into variable i.


    The title added to the image using title function then the axis is added to using axis function and named accordingly by using the xlabel() and ylable() functions.


    The colorbar function is used to add colour bar to the image, this is added to see how the colour map shows the specific intensity’s. Calculate the contrast image the calculation , max(max(double(i))), a , min (min)double(i))), b, will need to be executed , using the subtraction operator. The answer from the image contrast is then stored in to variable m which is then displayed using the disp function.


    Tutorial 2 exercise 3


    Aim of Exercise


    The aim of this exercise is to make a 10x10 image grid, b and from the co-ordinates ,x and y, and the intensity given by the user z, the calculation, image (x-co-ordinates , y co-ordinates)= intensity. The image will be again b , this time with the alteration to the pixels.


    Code


    % Title: Tut2ex3.m


    % Description:making a grid image


    % Author:0803939/2


    % Last Edit:30/september/2009


    b=zeros(10);


    imagesc( B) ;


    axis image;


    axis on;


    grid;


    colormap grey;


    x=input('enter x coordinate: ');


    y=input('enter y coordinate: ');


    z=input('enter intensitiy: ');


    b(x,y)=z;


    x=input('enter x co-ordinate: ');


    y=input('enter y co-ordinate: ');


    z=input('enter intensitiy: ');


    b(x,y)=z;


    x=input('enter x co-ordinate: ');


    y=input('enter y co-ordinate: ');


    z=input('enter intensitiy: ');


    b(x,y)=z;


    pens


    figure;


    imagesc( B) ;


    axis image;


    axis on;


    grid;


    colormap grey;


    Code description


    The 10x10 grid image is using the zeros() function and is sorted in variable b.


    Then the pixel of image is are made square from using the axis image function. The numeric axis are added using the axis on the function. A grid is added using the grid function and the image is made grey, using the colour map function and using the colour map grey. Image is then in b is now shown with the all above changes made to it.


    Use the input function to the co-ordinates to the values x and y and co-ordinate value y, and an intensity, z. From this data the following calculation is executed b(x,y)=z. The image stored in b is then displayed using the images() function with the pixels changed.


    Tutorial 2 exercise 4


    Aim of Exercise


    The aim of this exercise is to find the values of the pixels in an image and then to brighten the image and find the value of the same pixels in the brightened image.


    The image name, i , the pixel destination ,i, and how much the image is to be brightened by , b, is submitted by the user.


    Code


    % Title: Tut2ex4.m


    % Description: find the value of the pixels


    % Author:0803939/2


    % Last Edit:30/september/2009


    filename=input('Enter name of image to load:','s');


    i=imread(filename);


    imshow(i);


    x=input('enter x co-ordinate:');


    y=input('enter y co-ordinate:');


    p=i(x,y);


    disp(p);


    b=input('Enter amount to brighten by: ');


    brighten( B) ;


    axis on


    disp(p);


    Code description


    The input function allows the user to supply the image and load up and read and then store into a value, i.


    The user has to select a pixel position to find the value of , doing this by selecting the a x co-ordinate position , x, using the input function and a y, co-ordinate position, y, using again the input () function. Then image has the co-ordinates chosen and the value at this location is then stored in the variable i.


    The user then has to supply how much the image has to be brightening by; this is done by using the input function. Once brightness is selected it then is stored into variable b.


    Image is brighten by the value of b. One it has been brighten it is then displayed used the disp function.


    Tutorial 2 exercise 5


    Aim of Exercise


    Aim of this exercise is to be able to invert the image; the image will be submitted by the user.


    Code


    % Title : tut2ex5.m


    % Description :find the value of pixel


    % Author :0803939/2


    % Last Edit :30/september/2009


    filename=input('Enter name of image to load:','s');


    i=imread(filename);


    imshow(i);


    invert=255-i;


    colormap grey;


    imshow(invert);


    Code description


    The input function will allow the user to supply images to load up and read then will be stored in variable i. Inverting the image to 255 will take away the image stored in variable i, this will then be stored in variable m, using imshow() function the inverted image stored in m will be shown to the user.


    Tutorial 3 exercise 1


    Aim of Exercise


    The aim of this exercise is to make an if statement to report on a users homework grades. If the scores are greater than 8 they have passed if less then they have failed. The user will be required to enter a score, and from the that they will find out if they have passed or failed.


    Code


    % Title: Tut3ex1.m


    % Description: score input


    % Author:0803939/2


    % Last Edit: 6/october/2009


    score=input('how much did you score on this weeks quiz?');


    if(score>=8)


    disp('Congratulations you have passed!');


    else


    disp('Sorry you have failed!');


    end


    Code description


    The user will required to enter the score using the input() function. The score will be entered and the will be stored into variable score.


    If the grade stored into variable score is then even too or greater than 8. Then the message “congratulations you have passed!”. The quiz will be displayed by using the disp function.


    If you have failed the quiz getting less than 8, the message “ sorry you have failed” will appear, again used by the disp function.


    Tutorial 3 exercise 2


    Aim of Exercise


    This exercise will have 3 images to choose from and depending on the image chosen an image will be displayed to the user. The user will need to choose the image picture then depending on what image they an image corresponding to the number chosen will be displayed.


    Code


    % Title: Tut3ex2.m


    % Description:using if statement


    % Author:0803939/2


    % Last Edit:6/october/2009


    picture=input('What image would you like to open? ');


    if(picture==1)


    i=imread('moon.tif');


    imshow(i)


    elseif(picture==2)


    i=imread('cell.tif');


    imshow(i)


    elseif(picture==3)


    i=imread('mri.tif');


    imshow(i)


    else


    disp('Error');


    end


    Code description


    The disp function will pop up a message to the user showing them that they are allowed to from 3 images.


    Using the if statement is they user wants to load up image 1 by entering 1 into the input function picture choice, the image moon.tif will be read and stored into variable i. If any other number is selected then the cell.tif will load up.


    If the user wants to all 3 images and entering 3 into input() function the image mri.tif will be read and store into variable i.


    Tutorial 3 exercise 3


    Aim of Exercise


    The aim of the exercise is to evaluate the flow chart. The values given by the user will be their standard fare.


    Code


    % Title: Tut3ex3.m


    % Description:if statement


    % Author:0803939/2


    % Last Edit:6/october/2009


    age=input('How old are you? ');


    fare=input('Enter fare: ');


    if(age>=12)


    if(age<=24)


    rate=0.70;


    else


    rate=1.00;


    end


    else


    rate=0.00;


    end


    disp(rate*fare);


    Code description


    Using the input() function a will allow users to add values to their variables, age, fare


    Using the if statement if the values of variable age is under 12 , the rate will be set to 0.00 if the variable age is 12 and over and under 24 it will be set to 0.70. any other than these age groups will be 1.00.


    Tutorial 3 exercise 4


    Aim of Exercise


    The aim of this exercise is to make a switch case statement that will let the user to a animal aninal in which the program will then let them know what type of animal is chosen. The value of the variable animal is given by the user. If the value of the animal matches up to any animal in each case each type of animal then that animal will be shown by the user.


    Code


    % Title: Tut3ex4.m


    % Description:switch case


    % Author:0803939/2


    % Last Edit:6/october/2009


    animal=input('What animal type: ','s');


    switch lower(animal)


    case{'donkey', 'giraffe', 'elephant', 'zebra', 'dolphin'}


    disp('mammal');


    case{'pelican', 'puffin', 'seagul', 'parrot', 'pigeon'}


    disp('bird');


    case{'cod', 'rainbow fish', 'skate', 'bass', 'catfish'}


    disp('fish');


    case{'snake', 'cameleon' ,'gheko' , 'dinosaur', 'dragon'}


    disp('reptile');


    otherwise


    disp('animal not known ');


    end


    Code description


    Using the input()function the user can supply the name of an animal they wish to find out about this is then stored into variable animal. The switch case statement if the value of animal is equal to one the following 'donkey', 'giraffe', 'elephant', 'zebra', 'dolphin' then with the diap() function the message will display to the user.


    Using the input()function the user can supply the name of an animal they wish to find out about this is then stored into variable animal. The switch case statement if the value of animal is equal to one the following 'pelican', 'puffin', 'seagul', 'parrot', 'pigeon'}then with the diap() function the message will display to the user.


    The same goes for all the others animal groups.


    Using the otherwise statement, if the value of animal is anything else, then using the disp() function the user will be told that the type of the animal chosen is unknown.


    Tutorial 3 exercise 5


    Aim of Exercise


    The aim of this exercise is to an if else statement the 2 numbers supplied the user number 1 and number 2 can be chosen to add together 1 subtract 2 or be divided 3.


    Code


    % Title: Tut3ex5.m


    % Description: switch case


    % Author:0803939/2


    % Last Edit:6/october/2009


    number1=input('enter first number: ');


    number2=input('enter second number: ');


    operator=input('enter operator: ','s');


    switch operator


    case{'-'}


    answer=number1-number2;


    case{'+'}


    answer=number1+number2;


    case{'/'}


    answer=number1/number2;


    case{'*'}


    answer=number1*number2;


    end


    disp(answer)


    Code description


    using the input() function will allow the users to supply both of the numbers , variables number 1 and number 2 and to give what to do to these numbers by entering 1,2,3, then they are stored in variable1. Using a if else statement if 1 is typed in by the user then the equation number 1 + number 2 will be calculated using the addition operator + and will be displayed.


    If 2 is entered in by the user then the sum of number1-number2 will be calculated using the subtraction operator- , and then displayed.


    If 3 is entered by the user then the sum number1 / number 2 will be calculated using the division operator/, and then will be displayed.


    Tutorial 4 exercise 1


    Aim of Exercise


    This exercises aim is to show the times table up to 10 places of the number entered by the users number.


    Code


    % Title: Tut4ex1.m


    % Description:time table


    % Author:0803939/2


    % Last Edit: 16/october/2009


    number=input('Enter number: ');


    for counter=1:10


    counter=counter*number;


    disp(counter);


    end


    Code description


    Using the input()function will allow the user to supply the number of the times table they need to see which they will be stored in variable number. A for loop is made done with a counter , so that the counter will start on the variable number will grow by the variable number. It will end in variable number 10.


    Tutorial 4 exercise 2


    Aim of Exercise


    The aim of the exercise is to store many kinds of numbers into a variable. Variable, which the user will provide and from this variable its maximum number, mean and minimum number will be found and displayed to the users.


    Code


    % Title: Tut4ex2.m


    % Description:time table mean/max/min


    % Author:0803939/2


    % Last Edit:16/october/2009


    v=input('Enter the amount of numbers you want: ');


    for counter=1:v


    vec(counter)=input('Enter number: ');


    end


    m=max(vec);


    disp(['The max value entered is: ' num2str(m)]);


    m=mean2(vec);


    disp(['The mean of the value is: ' num2str(m)]);


    m=min(vec);


    disp(['The min value is: ' num2str(m)]);


    Code description


    Using the input() function will allow the user to enter how many numbers that they need to store in variable number. Using the loop will also allow the users to enter numbers using the input() function until they have entered the amount if times that user required to enter before and then stored un variable name


    Tutorial 4 exercise 3


    Aim of Exercise


    This exercise will allow the user to enter a number and using counters and while loop. When user enters the numbers -1 the counter will display to the user , letting them know how many numbers they entered before -1 then the mean max and min numbers of 1- will display to the user.


    Code


    % Title: Tut4ex3.m


    % Description:


    % Author:0803939/2


    % Last Edit:16/october/2009


    counter=1;


    choice=0;


    while(choice~=-1)


    choice=input('enter number: ');


    if (choice~=1)


    vec(counter)=choice;


    counter=counter+1;


    end


    end


    m=max(vec);


    disp(['The max value entered is: ' num2str(m)]);


    m=mean2(vec);


    disp(['The mean of the value is: ' num2str(m)]);


    m=min(vec);


    disp(['The min value is: ' num2str(m)]);


    Code description


    The counter index is started at 1 and that value is set to 0 and sets the loop to 1.


    Tutorial 4 exercise 4


    Aim of Exercise


    The aim if this exercise is to create a program that allows the user to put in a start number , and finish number along with a divisor. This will be sorted through 3 scalars number 1 number 2 and divisor. Value for number 1 and 2 entered from the user will be inserted to a counter.


    Code


    % Title: Tut4ex4.m


    % Description:counter


    % Author: 0803939/2


    % Last Edit:16/october/2009


    number1=input('enter first number: ');


    number2=input('enter second number: ');


    divisor=input('enter your divisor: ');


    for counter=number1:number2


    if(mod(counter,divisor)==0)


    disp(counter);


    end


    end


    Code description


    Using the input() function will allow the user supply values of the variables number 1 and number 2 and divisor which will contain the start and finish number of counter and the divisor.


    Tutorial 4 exercise 5


    Aim of Exercise


    The aim of this exercise is to make a 2d matrix using the for loops. The user will able supply the numbers of size grid and what they want to display, multiple. And using this variable and for loops the 2d matrix will be displayed to the users as the code as the image.


    Code


    % Title: Tut4ex5.m


    % Description:display matrixs


    % Author:0803939/2


    % Last Edit:16/october/2009


    multiple = input('enter the number you wish to multiply: ');


    for i = 1:multiple;


    for j = 1:multiple;


    matrix(i,j)=i*j;


    end


    end


    disp(matrix);


    imagesc(matrix);


    Code description


    Using the input () function will allow the user to supply a value of variable multiple a for loop will be used to the x x-axis on a grid from start 1 and finish at multiply. This will then be stored in variable x’


    Tutorial 6 exercise 1


    Aim of Exercise


    The aim of this exercise is to play around with a sound clip from the user and to calculate and the sample rate.


    Code


    % Title : tut6ex1.m


    % Description : Disp simples


    % Author : 0803939/2


    % Last Edit : 28/november/2009


    filename=input('enter.wav filename:','s');


    v=wavread('education.wav');


    wavplay (v);


    nbsamples=length(v);


    disp (nbsamples)


    [v rate]=wavread('education.wav');


    disp (rate)


    secs=nbsamples/rate;


    disp (secs)


    Code description


    Using the input()function the user is able to insert a sound vector to play, which is then stored in the variable file name. The song sample rate is the stored in the variable sound vector rate.


    Tutorial 6 exercise 2


    Aim of Exercise


    The aim is to change the frequency of the sound file submitted by the user.


    Code


    % Title : tut6ex2.m


    % Description :changing the frequency of a soundvector


    % Author :0803939/2


    % Last Edit :28/november/2009


    filename=input('enter.wav filename:','s');


    octaves=input('enter the frequency you want to increase:');


    v=wavread('education.wav');


    newpos=1;


    for i=1:Frown:2^octaves):length(v)


    h(newpos)= v(i);


    newpos= newpos+1;


    end


    figure;


    plot(v, 'r-');hold on;


    plot(h, 'g-');


    xlabel('sample number');


    ylabel('amplitude');


    title('sound frequency');


    wavplay (h);


    Code description


    Using the input() function, the user inserts the sound vector to open and read, which is stored in variable soundvector, and then played to the user using the wavread function. The user is also to supply how many frequency octaves to go up by, also using the input() function.


    Tutorial 6 exercise 3


    Aim of Exercise


    This aim is to see the average of sound file inserted by the user. To make the file sound sharper and smoother and to then save it in a new vector and display both original and modified file


    Code


    % Title : tut6ex3.m


    % Description :averages sound vector


    % Author :0803939/2


    % Last Edit : 28/november/2009


    filename=input('enter.wav filename:','s');


    v=wavread('education.wav');


    box=input('enter filter size:');


    b=zeros(length(v),1);


    for i=box+1:length(v)-box-1


    b(i)=mean(v(i-box:i+box));


    end


    figure;


    plot(v, 'r-');hold on;


    plot(b, 'g-');


    xlabel('sample number');


    ylabel('amplitude');


    title('box filter');


    wavplay ( B) ;


    Code description


    Using the input()function, this user is able to enter what they would like to read the listen to. The sound is read using wavread() function into variable soundvecotorchanged.


    Tutorial 6 exercise 4


    Aim of Exercise


    This aim is to ask the user to open the sound vector and decrease the frequency of sound which then needs to be stored in new sound vector.


    Code


    % Title : tut6ex4.m


    % Description :Grin:ecreasing a frequency of a sound vector


    % Author :0803939/2


    % Last Edit :28/november/2009


    filename=input('enter.wav filename:','s');


    v=wavread('education.wav');


    l=zeros(length(v)*2,1);


    newpos=1;


    for i=1:length(v)


    l(newpos)= v(i);


    l(newpos+1)= v(i);


    newpos= newpos+2;


    end


    figure;


    plot(v, 'r-');hold on;


    plot(l, 'g-');


    xlabel('sample number');


    ylabel('amplitude');


    title('sound frequency');


    wavplay (l);


    Code description


    Using the input() input function will allow the user to enter any image they like and would to read and listen to. The sound is read through the wavread() function and then stored in the variable soundvectorchanged.


    Tutorial 6 exercise 5


    Aim of Exercise


    The aim of the exercise is to change the program where the frequency of sound vector had been decreased.


    Code


    % Title : tut6ex5.m


    % Description :modify samples


    % Author :0803939/2


    % Last Edit : 28/november/2009


    filename=input('enter.wav filename:','s');


    v=wavread('education.wav');


    l=zeros(length(v)*2,1);


    newpos=1;


    for i=2:length(v)-1


    l(newpos)= v(i);


    l(newpos+1)=(v(i-1)+v(i+1))/2;


    newpos= newpos+2;


    end


    figure;


    plot(v, 'r-');hold on;


    plot(l, 'g-');


    xlabel('sample number');


    ylabel('amplitude');


    title('sound frequency');


    wavplay (l);


    Code description


    Using the input () function the user is able to enter what they would like to read and listen to. The sound is read the wavrea() function and stored into variable soundvectorchange .
     
    Last edited by a moderator: Friday 11th Dec, 2009
  2. morris Valued Contributor ★ ★ ★ ☆ ☆

    697
    Well done lad, is that VB?


    ;_______________________________


    ;


    ; James Morris


    ; Morgan Professional Services


    ; Programming Concepts Project


    ; Parametric Bush Program


    ; JM_AUTOBUSH.LSP


    ;


    ;
     
  3. a2k00 Club Veteran ★ ★ ★ ★ ★

    Sooo glad I didnt become a code monkey, I couldt stare at that shit all day, Give credit where credit is due, That is some good shit mate, I think ill stick with networking and project management, lol
     
  4. Naj_Ej Club Veteran ★ ★ ★ ★ ★

    im just glad its over! gona go in hand my work in and enjoy a nice 7 weeks of hoilday now.
     
  5. Naj_Ej Club Veteran ★ ★ ★ ★ ★

     
  6. morris Valued Contributor ★ ★ ★ ☆ ☆

    697
    hahaha.. you didn't have to quote my entire post lad. 7... weeekss... thats a piss take.


    @ a2k00, a lot of people, like my self don't program for a living, I use it as a means to an end. I develope mods for autocad to help me and my fellow designers to be more productive, simples. :Grin:
     
  7. Naj_Ej Club Veteran ★ ★ ★ ★ ★

    lol morris soz lol. yup yesterday was my last day (10th) and IMA back on like 25th of jan lol. got better modules in semsta 2 . no offence to all the programers but i can't stand it!
     
  8. a2k00 Club Veteran ★ ★ ★ ★ ★

    Thats cool, I've started to learn PHP, But got bored, lol
     
  9. Naj_Ej Club Veteran ★ ★ ★ ★ ★

    i think most people who like programming it come natraul to them.
     
  10. F3RG1E Valued Contributor ★ ★ ★ ☆ ☆

    609
    oh god, just when i thought i had escaped things like Matlab/Programming etc i feel they are stalking me *slowly looks over both shoulders*


    What course you doing ? We used a lot of Matlab in the electrical & electronics engineering degree course that I've just recently finished.
     
  11. Naj_Ej Club Veteran ★ ★ ★ ★ ★

    iam doing muiltimedia computing. i hate matlab so do 120 other students lol