Including jsbs in my Matlab code

I am trying to develop Matlab code for a flight simulator and want to include jsbs in the code. Not sure how best to do it i.e. in a cmd line - or is there a better way?

 Accepted Answer

Star Strider
Star Strider on 16 Feb 2026 at 18:52
Are you interested in using it with the Aerospace Toolbox? Since JSBSim is designed to run independently under several different operting systems, and since it does not mention MATLAB in its online documentation, you will need to contact MathWorks to see how you can integrate it into MATLAB.
It would probably help if you are a bit more specific about how you want to integrate it into MATLAB in your note to them.

18 Comments

JSBSim is written in C++, so in theory you might be able to call the code from MATLAB, perhaps using https://www.mathworks.com/help/matlab/use-prebuilt-matlab-interface-to-c-library.html
Ken
Ken on 17 Feb 2026 at 1:11
I assumed the file already exists in jsbsim so tried the line [aircraft, state] = jsbsimToFixedWing(aircraft, 'c172r\c172r.xml', 'JSBSimRoot', 'c:\jsbsim'); but got error 'Invalid argument at position 2. These files do not exist: 'c172r\c172r.xml'. Was looking for trying to get directly to jsbsim'
It seems that you will need to examine your JSBSim installation to be certain the necessary files were installed in the correct directories or subdirectories so that the calling routine can find them. It might also be worthwhile contact the authors and request information on where everything is supposed to be installed if that is not already available.
I know nothing more about JSBSim than I wrote earlier. (I'm an Instrument-Rated Private Pilot, so the concept interests me.)
Try providing an absolute path to the files instead of a relative path.
Ken
Ken on 18 Feb 2026 at 3:59
The absolute path is lengthy i.e. C:\Users\User\Downloads\jsbssim-1.2.4\aircraft\c172r.
Wonder if there is a shortcut to this?
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r\c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
Ken
Ken on 18 Feb 2026 at 16:58
Thanks. Now have to get c172r.xml file and its directory.
You need to move or copy it to from your 'Downloads' directory to wherever it needs to be in JSBSim. You can probably do that manually. (JSBSIm probably needs to be in its own directory, not 'Downloads', as do the files it needs to access.)
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
get error: jsbs
Error using Aero.FixedWing/jsbsimToFixedWing
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invalid argument at position 2. These files do not exist: 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft/c172r.xml'.
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
get error: jsbs
Error using Aero.FixedWing/jsbsimToFixedWing
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invalid argument at position 2. These files do not exist: 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft/c172r.xml'.
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
get error: jsbs
Error using Aero.FixedWing/jsbsimToFixedWing
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invalid argument at position 2. These files do not exist: 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft/c172r.xml'.
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
get error: jsbs
Error using Aero.FixedWing/jsbsimToFixedWing
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invalid argument at position 2. These files do not exist: 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft/c172r.xml'.
If the files are in your 'Downloads' directory, they have not been installed. They're just sitting there, waiting for you to install them.
You have to copy/move them (I prefer copying, at least initially) to the appropriate directory that you create for JSBSim, then install the calling routine to that directory, and give it the appropriate paths to each 'aircraft' file.
The Getting Started page tells you how to install and use JSBSim (current as of 25 Apr 2025). Apparently, you will need to use the appropriate installer, if you haven't already done that. That documentation says that will install JSBSim.exe, aeromatic.exe, aircraft, enigne and systems data, and MATLAB S-function files.
The installer version on that page is JSBSim-1.2.2-setup.exe, however you may be using a later version.
Your previous code had the file located at c172r\c172r.xml so I created basedir assuming that you would continue to reference c172r\c172r.xml . If the files are at C:\Users\User\Downloads\jsbssim-1.2.4\aircraft\c172r\c172r.xml then using a basedir of C:\Users\User\Downloads\jsbssim-1.2.4\aircraft and a local component of c172r.xml would not be able to find the file, as it would be missing the c172r directory component.
Ken
Ken on 19 Feb 2026 at 20:27
Moved: Star Strider on 19 Feb 2026 at 21:05
I have put the files in the correct directories. Used these lines of code:
basedir = 'C:\Users\User\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbssimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), ...
'JSBSSimRoot', 'c:\jsbssim');
I used this path: C:/Users/User/jsbssim-1.2.4/aircraft/c172r/c172r.xml but still get:
>>jsbs
Unrecognized function or variable 'jsbssimToFixedWing'.
Error in jsbs (line 9)
[aircraft, state] = jsbssimToFixedWing(aircraft, fullfile(basedir,'c172r.xml'), 'JSBSSimRoot', 'c:\jsbssim');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Be certain that you installed JSBSim correctly.
Searching further a few minutes ago, I found JSBSim Open Source Flight Dynamics Model. That seems to have significantly more documentation, including the JSBSim Reference Manual (PDF).
I'm considering installing it myself, although I'm using Ubuntu 24.04, so my installation would likely not have the same directory structure yours would.
Ken
Ken on 19 Feb 2026 at 22:18
Moved: Star Strider on 19 Feb 2026 at 22:48
I checked and the dir/files I dloaded under jsbssim are: .github, admin, aircraft..............README. Is it possible to tell from this if jsbssim is dloaded properly?
Star Strider
Star Strider on 19 Feb 2026 at 22:48
Moved: Star Strider on 19 Feb 2026 at 22:48
I can't determine that. I looked through a number of search results for JSBSim and could not find that informaiton. (There are only a limited number of search results, most of them duplicates of the original JSBSim documentation.)
Run it according to the documentation instructions and see if it runs as it should, or produces any errors if it doesn't. That's likely the best way to see if it's installed correctly.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

Ken
on 16 Feb 2026 at 16:29

Moved:

on 19 Feb 2026 at 22:48

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!