You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Including jsbs in my Matlab code
51 views (last 30 days)
Show older comments
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
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
Walter Roberson
on 16 Feb 2026 at 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
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'
Star Strider
on 17 Feb 2026 at 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
on 17 Feb 2026 at 5:04
Try providing an absolute path to the files instead of a relative path.
Walter Roberson
on 18 Feb 2026 at 4:24
basedir = 'C:\Users\User\Downloads\jsbssim-1.2.4\aircraft';
[aircraft, state] = jsbsimToFixedWing(aircraft, fullfile(basedir,'c172r\c172r.xml'), 'JSBSimRoot', 'c:\jsbsim');
Star Strider
on 18 Feb 2026 at 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
on 19 Feb 2026 at 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
on 19 Feb 2026 at 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
on 19 Feb 2026 at 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
on 19 Feb 2026 at 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
on 19 Feb 2026 at 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
about 4 hours ago
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
about 3 hours ago
Moved: Star Strider
about 3 hours ago
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
about 3 hours ago
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
about 1 hour ago
Moved: Star Strider
about 1 hour ago
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
about 1 hour ago
Moved: Star Strider
about 1 hour ago
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.
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)