regarding matrix

Discussion in 'MATLAB' started by Amandeep Singh, Dec 11, 2006.

  1. hello

    I want to display multiplication of matrix with x and y in a similar
    way displayed as sum of x and y.
    a = input('enter the no of loop =')
    for i=1:a
    x = input('enter the value of x=')
    y = input ('enter the value of y=')
    c =x+y
    end

    If I entered number of loop =2
    x=2 and y=3
    then c=5
    for second loop
    I entered x=3 and y=4
    then c = 7
    the final result is
    c =

    5 7

    In second programm I used one matrix in prog..as

    a = input('enter the no of loop =')
    for i=1:a
    x = input('enter the value of x=')
    y = input ('enter the value of y=')
    s=[1 5 8; 3 1 5;4 9 0]
    c(i) =x+y
    end
    the result is

    ??? In an assignment A(I) = B, the number of elements in B and
    I must be the same.

    Error in ==> trial at 8
    c(i) =x+y

    Please help me out in this..
     
    Amandeep Singh, Dec 11, 2006
    #1
    1. Advertisements

  2. Amandeep Singh

    Jérôme Guest

    Hi,

    both examples works.

    Jérôme
     
    Jérôme, Dec 11, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.