If you need MatLab help, plz message

Discussion in 'Programmer's Corner' started by Brandon, Dec 30, 2004.

  1. Brandon

    Thread Starter Senior Member

    Dec 14, 2004
    306
    0
    I have a lot of experience with MatLab in a handfull of areas and if anyone runs into some issues, please be sure to post or message me.

    I'll be glad to help.
     
  2. braddy

    Well-Known Member

    Dec 29, 2004
    83
    0

    Hey Brandon,
    I am happy to hear that. I have another exercice. Me too, I would like to have as good as you on Matlab.
    This is another problem:

    Suppose that the function file bounds.m and the script file main.m as indicated below are in the current directory. If main.m is "run", what would you expect to see in the command window?

    main.m

    clear;
    x=[1:.1:2];
    n=5;
    [xl,xu]=bounds(2.9);
    disp('lower upper');
    disp([xl,xu]);
    z=[3.5,-1.4,8.9];
    [zl,zu]=bounds(z);
    disp([zl',zu']);
    disp(n);
    a=[4.2,-1.1;3.7,-6.3];
    [al,au]=bounds(a);
    disp([al,au]);
    disp(n);


    Here is the function bounds that is used in solve main.m:

    bounds.m

    function [beneath,above] = bounds(x)
    %function to find glb and lub for x
    [n,m]=size(x);
    if (n>1)&(m>1)
    error('Function not valid for
    2-D arrays');
    else
    above=ceil(x);
    beneath=floor(x);
    end


    Do you have an personal email?

    Thanks
    B.
     
  3. Brandon

    Thread Starter Senior Member

    Dec 14, 2004
    306
    0
    Alright, the bounds.m function generates 2 arrays representing the intenger boundaries from a single input array.

    [xl,xu]=bounds(2.9); would give us
    xl=2 xu=3
    [2 3]

    z=[3.5,-1.4,8.9];

    You should see something like this on the screen

    lower upper
    2 3
    3 4
    -2 -1
    8 9
    5
    Function not valid for 2-D array
    0 0
    5

    or something very very similar to this.
     
Loading...