f



MatLab Basics Question

Hello.  I'm extremely new to MatLab.  I'm a student... and I have an assignement that requires me to use it.  No, I'm not asking for "Can someone do my homework?"  I need help with the basics.  My professor gave my class a 5 minute tutorial, and then gave us this crazy assignment.. and I'm lost.  How do I set up the following in MatLab?  I have no clue...

The S-MF with two parameters l and r (l<r) is an S-shaped open-right Membership FUnction defined by:
                           |  0,                                     for x<= 1,
S(x;l,r))=        ---+  2((x-l)/(r-l))^2,               for l < x <= (l+r)/2
                           |  1-2((r-x)/(r-l))^2            for (l+r)/2 < x <= r
                           +  1,                                     for r < x

The Z-MF with two parameters l and r (l<r) is a Z-shaped open-left Membership Function defined by:

                                   + 0,                             for x<= 1
                                   | 2((x-l)/(r-l))^2,         for l<x<=(l+r)/2
Z(x;l,r) =1-S(x;l,r)= --+ 1-2((r-x)/(r-l))^2     for (l+r)/2<x<=r
                                   |  1,                             for r<x

I need to write MatLab functions to implement these before I can even do my assignment... but i have no idea how.
Any help would be greatly appreciated!
THanks!
0
blendax78 (1)
11/2/2008 1:23:02 PM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

4 Replies
828 Views

Similar Articles

[PageSpeed] 12

On Nov 2, 8:23=A0am, "Eric Vintimilla" <blenda...@yahoo.com> wrote:
> Hello. =A0I'm extremely new to MatLab. =A0I'm a student... and I have an =
assignement that requires me to use it. =A0No, I'm not asking for "Can some=
one do my homework?" =A0I need help with the basics. =A0My professor gave m=
y class a 5 minute tutorial, and then gave us this crazy assignment.. and I=
'm lost. =A0How do I set up the following in MatLab? =A0I have no clue...
>
> The S-MF with two parameters l and r (l<r) is an S-shaped open-right Memb=
ership FUnction defined by:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A00, =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for x<=3D 1=
,
> S(x;l,r))=3D =A0 =A0 =A0 =A0---+ =A02((x-l)/(r-l))^2, =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 for l < x <=3D (l+r)/2
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A01-2((r-x)/(r-=
l))^2 =A0 =A0 =A0 =A0 =A0 =A0for (l+r)/2 < x <=3D r
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+ =A01, =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for r < x
>
> The Z-MF with two parameters l and r (l<r) is a Z-shaped open-left Member=
ship Function defined by:
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+ =
0, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for x<=3D 1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =
2((x-l)/(r-l))^2, =A0 =A0 =A0 =A0 for l<x<=3D(l+r)/2
> Z(x;l,r) =3D1-S(x;l,r)=3D --+ 1-2((r-x)/(r-l))^2 =A0 =A0 for (l+r)/2<x<=
=3Dr
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =
=A01, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for r<x
>
> I need to write MatLab functions to implement these before I can even do =
my assignment... but i have no idea how.
> Any help would be greatly appreciated!
> THanks!

----------------------------------
Eric:
A bunch of if statements inside the function definition should do it.
Just check the value of "x" in an if-elseif-elseif-else statement and
you can do it.  Same basic structure that you would do in any language
so if you can program in any language, you should be all ready to go.
Just check the help documentation for the if statement to get the
syntax right.  Alternatively you can use a switch statement.
Good luck
ImageAnalyst
0
imageanalyst (7621)
11/2/2008 5:00:27 PM
Eric Vintimilla wrote:

> The S-MF with two parameters l and r (l<r) is an S-shaped open-right Membership FUnction
> defined by:
>                            |  0,                                     for x<= 1,
> S(x;l,r))=        ---+  2((x-l)/(r-l))^2,               for l < x <= (l+r)/2
>                            |  1-2((r-x)/(r-l))^2            for (l+r)/2 < x <= r
>                            +  1,                                     for r < x

What value should it have if r < x <= 1 ? According to the first line, it must have value 0
because then x <= 1, but according to the 4th line it would have to have value +1 because
r < x.

If one takes the top-most constraint as having highest priority, then consider code
of the form

if x <= 1
  result = 0;
elseif l < x && x <= (l+r)/2
  result = 2*((x-l)/(r-l)).^2;
elseif <etc>
end


If you need to extend this to handle a vector of x values, you should look up
"logical indexing" in the Matlab documentation.

-- 
..signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?
0
roberson (2980)
11/2/2008 5:14:11 PM
hey guys. Can anyone mail the matlab code for the above mentioned problem. my mail id is shaik486@gmail.com.
0
shaik486 (1)
1/28/2015 4:59:13 PM
Reply: