Results 1 to 4 of 4

Math Help - What command whould i use?

  1. #1
    Newbie
    Joined
    Sep 2009
    Posts
    2

    What command whould i use?

    hi all, im not sure if this is the right place to ask, but i hope so ^^

    im looking for an solution for my problem. im currently working in Matlab with an while loop witch calculates something for me, but he need's to do this 10000 times, so i made an while loop for it. so in the of the round of the loop it for example the number 10. im looking for an way to save this number.

    the code i wrote is this (note: the ____ are just to make the reading fo the matrix easier, i left them out in the orignal code)
    ____________________________

    %inserting values
    R = 12000
    C = 1.6e-9
    n = 0

    %the while loop

    while n<5

    n = n+1;
    f(n)=n;


    RC= 1/(j*2*pi*f(n)*C);
    tRC=2/(j*2*pi*f(n)*C);

    %insert of matrix 1

    M1 = _[0___________(2/R)+(1/tRC)_(-1/R);
    ______(2/RC)+(2/R)__0____________(1/RC);
    ______(-1/RC)______(-1/R)________(2/RC)];


    %insert of matrix 2
    M2 = __[10/R;
    _______10/RC;
    _______0];


    %calculate unknown values in the matrix
    M = M1\M2

    Vin = 10

    %grab the value i need or my calculation
    Vout= M(3,1)
    H = Vout/Vin
    end
    _____________________________

    so, now im looking for an way to store the value of H so i can plot into an graph later, any ideas how i can do this?
    Last edited by mr fantastic; September 23rd 2009 at 05:09 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member Twig's Avatar
    Joined
    Mar 2008
    From
    Gothenburg
    Posts
    396
    Hi

    You could make a vector which you create before the while loop.
    Lets call it A.

    A=[]; %Create empty vector

    Now in each loop, write

    A=[A 'Your new number you wish to save'];

    This way you should be able to save all the numbers, one new with every loop.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Sep 2009
    Posts
    2
    it works smoothly , thanks a lot
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Assuming H is a scalar:

    Code:
     
    %inserting values
    R = 12000
    C = 1.6e-9
    n = 0
    HH=[];  %empty array to hold the output
     
    %the while loop
     
    while n<5
     
      n = n+1;
      f=n;
     
     
      RC= 1/(j*2*pi*f*C);
      tRC=2/(j*2*pi*f*C);
     
      %insert of matrix 1
     
      M1 = [0 (2/R)+(1/tRC)_(-1/R);
           (2/RC)+(2/R) 0 (1/RC);
           (-1/RC) (-1/R) (2/RC)];
     
     
      %insert of matrix 2
      M2 = [10/R;
            10/RC;
            0];
     
     
      %calculate unknown values in the matrix
      M = M1\M2
     
      Vin = 10
     
      %grab the value i need or my calculation
      Vout= M(3,1)
      H = Vout/Vin
      HH=[HH,H];  % stuff result into extended output array
    end
    

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. rref command
    Posted in the Calculators Forum
    Replies: 1
    Last Post: May 14th 2011, 09:08 AM
  2. [SOLVED] Left hand alignment in the matrix command and array command
    Posted in the LaTeX Help Forum
    Replies: 8
    Last Post: May 3rd 2011, 02:31 PM
  3. Latex command!
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: December 17th 2010, 11:04 AM
  4. MATLAB: The cat command
    Posted in the Math Software Forum
    Replies: 4
    Last Post: July 13th 2010, 01:32 PM
  5. command for..?
    Posted in the LaTeX Help Forum
    Replies: 9
    Last Post: November 2nd 2007, 05:40 AM

Search Tags


/mathhelpforum @mathhelpforum