Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:16:43+00:00 2026-06-07T03:16:43+00:00

i want fsolve to calculate the output for different uc each time (increasing uc

  • 0

i want fsolve to calculate the output for different uc each time (increasing uc by 0.001 each time). each output from fsolve should be sent to a simulink model seperatly. so i set a loop to do so, but i believe that at the currenty constellation (if it will work)will just calculate 1000 different values? is there a way to send out the values seperately?

if not, how can i create a parameter uc. that goes from 0 to say 1000? i tried uc=0:0.001:1000, but again, the demension doen’t seem to fit.

how do i create a function that takes the next element of a vector/matrix each time the function is called?

best regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:16:45+00:00Added an answer on June 7, 2026 at 3:16 am

    The general approach to iterating over an array of values and feeding them one-by-one into a series of evaluations of a function follows this form:

    for ix = 0:0.1:10
       func(arg1, arg2, ix)
    end
    

    See how each call to func includes the current value of ix ? On the first iteration ix==0, on the next ix==0.1 and so forth. You should be able to adapt this to your needs; in your code the loop index (which you call i) is not used inside the loop.

    Now some un-asked-for criticism of your code. The lines

    x0=[1,1,1];
    y=x0(1);
    u=x0(2);
    yc=x0(3);
    options=optimset('Display','off'); 
    

    do not change as the loop iterations advance; they always return the same values whatever the value of the loop iterator (i in your code) may be. It is pointless including them inside the loop.

    Leaving them inside the loop may even be a waste of a lot of time if Matlab decides to calculate them at every iteration. I’m not sure what Matlab does in this case, it may be smart enough to figure out that these values don’t change at each iteration, but even if it does it is bad programming practice to write your code this way; lift constant expressions such as these out of loops.

    It’s not clear from the fragment you’ve posted why you have defined y, u and yc at all, they’re not used anywhere; perhaps they’re used in other parts of your program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to solve an equation for a different value in each cycle of
Want to run javascript function from parent window in child window Example I have
Want to open firefox from terminal at linux with firebug enabled // Terminal $
Want to extract the text value from a lookup table's column in a db.
want to share a link from my application in windows phone 7. Any one
Want to pause the multiple views from updating when Pause button is pressed In
Want i want to do is i get a number from a php script.
Want to detect the '\n' without going through each and every character of a
want to make a comma-delimited string from a list of 3 possible attributes of
want to make values of the oject's dynamic (from user input) but I get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.