×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NEWBIE function with sum of multiple parameters

NEWBIE function with sum of multiple parameters

NEWBIE function with sum of multiple parameters

(OP)
I am very new to Matlab and such programms generally. I want to implement such a function:

y = sum(Xi) where i = 1 to 20
Xi are unknown parameters. how can I do this to Matlab?

Of course i can do: y= x1 + x2 + x3... but it's ridiculous.

My final target is to minimize such a function with genetical algorithms. Of course this is not the real function. It's simply demonstrates what I need to learn. Thank you all

RE: NEWBIE function with sum of multiple parameters

I'm not sure that I totally understand your issue. It seems that you have the answer in your question, which is why I say this. If you have an array i defined as "i = [1,2,3,4,5,6,7,8,9,10]" and you use the function "y = sum(i)", Matlab will provide you the answer y = 55. In other words, the function already exists. Perhaps I'm not interpreting your question correctly.

RE: NEWBIE function with sum of multiple parameters

(OP)
Well I found a solution. Sorry for not syntaxing my question right. With the solution you will understand my question too :)

r = func(x)

r=0;

for i=0:20
r= r+ sum(x(i));
end

so func is a function with 20 unknown variables x(1) ... x(20)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources