# If you need MatLab help, plz message

#### Brandon

Joined Dec 14, 2004
306
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.

Joined Dec 29, 2004
83
Originally posted by Brandon@Dec 30 2004, 01:21 PM
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.

[post=4359]Quoted post[/post]​

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.

#### Brandon

Joined Dec 14, 2004
306
Originally posted by braddy@Dec 30 2004, 04:52 PM
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.
[post=4365]Quoted post[/post]​
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.