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?

 Respuesta aceptada

Star Strider
Star Strider el 16 de Feb. de 2026 a las 18:52

0 votos

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 comentarios

Walter Roberson
Walter Roberson el 16 de Feb. de 2026 a las 19:54
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 el 17 de Feb. de 2026 a las 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'
Star Strider
Star Strider el 17 de Feb. de 2026 a las 1:22
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.)
Walter Roberson
Walter Roberson el 17 de Feb. de 2026 a las 5:04
Try providing an absolute path to the files instead of a relative path.
Ken
Ken el 18 de Feb. de 2026 a las 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?
Walter Roberson
Walter Roberson el 18 de Feb. de 2026 a las 4:24
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r\c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
Ken
Ken el 18 de Feb. de 2026 a las 16:58
Thanks. Now have to get c172r.xml file and its directory.
Star Strider
Star Strider el 18 de Feb. de 2026 a las 17:33
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.)
Ken
Ken el 19 de Feb. de 2026 a las 15:16
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'.
Ken
Ken el 19 de Feb. de 2026 a las 15:16
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'.
Ken
Ken el 19 de Feb. de 2026 a las 15:16
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'.
Ken
Ken el 19 de Feb. de 2026 a las 15:16
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'.
Star Strider
Star Strider el 19 de Feb. de 2026 a las 16:01
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.
Walter Roberson
Walter Roberson el 19 de Feb. de 2026 a las 19:18
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 el 19 de Feb. de 2026 a las 20:27
Movida: Star Strider el 19 de Feb. de 2026 a las 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');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Star Strider
Star Strider el 19 de Feb. de 2026 a las 21:15
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 el 19 de Feb. de 2026 a las 22:18
Movida: Star Strider el 19 de Feb. de 2026 a las 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 el 19 de Feb. de 2026 a las 22:48
Movida: Star Strider el 19 de Feb. de 2026 a las 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Ken
el 16 de Feb. de 2026 a las 16:29

Movida:

el 19 de Feb. de 2026 a las 22:48

Community Treasure Hunt

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

Start Hunting!

Translated by