Preview

MATLAB Exercise: Artificial Intelligence

Good Essays
Open Document
Open Document
332 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
MATLAB Exercise: Artificial Intelligence
MATLAB EXERCISES
UEMH3163 / UECS2053 ARTIFICIAL INTELLIGENCE

1. Run the MATLAB code: a = 1:5; d = a+i*a; e = d' f = d.' g = mod(5,4)
2. Given A = [1 2 4; 1 1 1; 2 3 1] and B = [2 2 2; 2 2 2; 2 2 2]. Run the MATLAB code: a=A>B b=A>1
3. Given A = magic(4). Run MATLAB code :
DiagElement = diag(A)
DiagMatrix = diag(diag(A))
SuperDiagElement = diag(A,2)
4. Run the MATLAB code: name = upper('matlab') fun = strrep('hahaha','a','i') greet = 'Welcome'; where = 'to Joan''s'; party = 'birthday party';
¯nal = str2mat(greet, where, party) text = 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday';
[day,rest] = strtok(text,',')
[day2,rest] = strtok(rest,',')
5. Given A = [1 1; 2 2; 3 3; 4 100]. Run the MATLAB code : average = mean(A) med = median(A) dev = std(A)
6. Given A = [0 4 4; 2 0 2; 4 2 0]. Run the MATLAB code :
[Ascend,Ind] =sort(A)
Descend = flipud(sort(A))
7. Let be given the string 'Need-to-split-this-string'. We want to break it into the 5 strings 'Need', 'to',
'split', 'this', and 'string'.
8. Given A = [1 2 5 5 6 2 1 2]. Write a code that removes all 2's in matrix A.
9. Given A = [2 8 3 30 4 50 100 200 4 80 500]. Split it into three arrays with different ranges: (0-10),
(10-100), and (100-1000). The above array should become a = [2 8 3 4 4] b = [30 50 80] c = [100; 200; 500]

10. Given A = [1 2 3;4 5 6;7 8 10] and B = [1 2 5;3 5 -6]. Run MATLAB code :
A+B
A*A
A^2
B*A
A*B
A’
A.^2
[1,2,3].*[4,7,4]
[15 14 17]./[3 2 17]
[1 2 3]./[4 5]
11. Write a code to generate following outputs d = [-5 -4 -3 -2 -1 0 1 2 3 4 5] d = [1 4 7 10]
12. Given u = [1 0 2 4 0 2] and v = [5 6 1 0 0 7]. Run the following codes : u&v u|v
~u
u == 2 xor(u,v) any(v) all(v) find(u == 2)
13. Given A = magic(4). Run MATLAB codes :
A>13
x = find(A>13)
A(x) = 999
14. Write a loop that adds up random numbers, but makes sure that the sum of random numbers x stays below 20.0.
15. Write a for loop that adds up the numbers from 1 to

You May Also Find These Documents Helpful

  • Good Essays

    Mman2400-June 2007 Paper

    • 595 Words
    • 12 Pages

    The boom is supported by the winch cable that has a diameter of 6 mm and an allowable normal stress of O"allow 170 MPa. Determine the greatest load including the cage that can be supported without causing the cable to fail when 0 = 30°, and…

    • 595 Words
    • 12 Pages
    Good Essays
  • Satisfactory Essays

    EIC and Tax Tables

    • 13897 Words
    • 56 Pages

    $1 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1,000 1,050 1,100 1,150 1,200 1,250 1,300 1,350 1,400 1,450 1,500 1,550 1,600 1,650 1,700 1,750 1,800 1,850 1,900 1,950 2,000 2,050 2,100 2,150 2,200 2,250 2,300 2,350 2,400 2,450…

    • 13897 Words
    • 56 Pages
    Satisfactory Essays
  • Good Essays

    metcs520 W4 Assignment

    • 637 Words
    • 8 Pages

    of the first red block in the bottom row. The next two values are the…

    • 637 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit Qcf643 Answers

    • 603 Words
    • 2 Pages

    0 8 4 5 4 6 7 8 1 2 00 8 4 5 4 6 7 8 1 2 0…

    • 603 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    The aim of this guide is to teach you the basics of using a range of formulas in Microsoft Office Excel; this guide covers the following formulas: Addition; Subtraction, Multiplication, Division, Average & Percentage.…

    • 2823 Words
    • 12 Pages
    Good Essays
  • Good Essays

    In the range B8:H16, create a two-variable data table. Set B3 as the row input cell, and B4 as the column input cell.…

    • 566 Words
    • 3 Pages
    Good Essays
  • Good Essays

    unit 8 homework

    • 793 Words
    • 5 Pages

    4. Design a loop that asks the user to enter a number. The loop should iterate 10 times and keep a running total of the numbers entered.…

    • 793 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Problems1

    • 605 Words
    • 2 Pages

    2. Let Vn be the Vandermonde matrix for n equally spaced points between 0 and 1. Do you…

    • 605 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Inch and Lt

    • 1077 Words
    • 5 Pages

    c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.…

    • 1077 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    code program

    • 317 Words
    • 2 Pages

    (Input screenshot) - Insert here a screenshot of your program running showing entry of the provided set of test input data for this assignment:…

    • 317 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    be considered, where x1 , x2 , ... , xn are the unknowns, elements aik (i = 1, 2, ..., m;…

    • 3080 Words
    • 13 Pages
    Good Essays
  • Good Essays

    Week 1 Homework

    • 843 Words
    • 5 Pages

    c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.…

    • 843 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    cachematrix1

    • 270 Words
    • 2 Pages

    x <<- y ## assign the input matrix y to the variable x in the…

    • 270 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Apriori Algorithm

    • 2095 Words
    • 9 Pages

    TID T100 T100 T100 T100 T100 T100 T100 T100 T100 List of Items I1, I2, I5 I2, I4 I2, I3 I1, I2, I4 I1, I3 I2, I3 I1, I3 I1, I2 ,I3, I5 I1, I2, I3…

    • 2095 Words
    • 9 Pages
    Powerful Essays