Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/fsolve with multiple parameters

fsolve with multiple parameters

PuTI / 2025-01-17
fsolve with multiple parameters
Matlab News

I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you.I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you. I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you. fsolve, input, function, embedded matlab function MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

test one two three four
2025-05-20

test one two three four

Is it possible to make this tiny loop faster?
2025-05-19

Is it possible to make this tiny loop faster?

Solar Wind Battery Hybrid Integration
2025-05-19

Solar Wind Battery Hybrid Integration

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss