Simscape Battery - Battery Charging and Discharging Example

2 views (last 30 days)
I have the Simscape Battery Add On installed and the MATLAB R2023b version installed, but I am having trouble accessing the "Battery Charging and Discharging" example. I have copied the command and run it from the Command Window, but it says it can't find the example each time. I have searched the installed Math Works folder, but the example doesn't exist. Does anyone else have access to this example? If so, can you share with me.

Accepted Answer

atharva
atharva on 10 Nov 2023
Hey James,
I understand that you are not able to open the Battery Charging and Discharging example even though you do have Simscape Battery Add On installed and the MATLAB R2023b version installed.
Usually this happens when the example files are not installed on not currently located on the MATLAB search path. There are several possible explanations:
1. Check which support packages are currently installed on your machine. For instance, if the support package is properly installed you will see the following:
>> matlabshared.supportpkg.getInstalled
Name Version Base Product
-----------------------------------------------------------------------
<Support Package Name> XX.Y.Z <Base Product Name>
2. Check the location of the Support Package Root Directory using the following commands:
>> matlabshared.supportpkg.getSupportPackageRoot
This should return a location similar to the following:
'C:\ProgramData\MATLAB\SupportPackages\RXXXXy'.
Typically, example files are located somewhere off this directory. They may be located in a sub-directory tied to a particular toolbox or set of examples, such as:
‘C:\ProgramData\MATLAB\SupportPackages\RXXXXy\toolbox\<Toolbox Name>\supportpackages\<Support Package Name>\<examples>’
The "examples" directory typically contains code and/or model files needed to run the examples included with the support package.
Please navigate to the equivalent location on your machine and confirm that the files are located there.
3. If the files do not appear there, please follow the instructions in the following article to re-install the Support Package.
4. Once you have confirmed that the files do exist in that directory, use the 'which' command to identify if the files exist on the MATLAB Path.
>> which example_filename.m
For example, this should return a path location similar to what is shown below:
‘C:\ProgramData\MATLAB\SupportPackages\RXXXXy\toolbox\<Toolbox Name>\supportpackages\<Support Package Name>\<examples>\example_filename.m’
If ‘which’ returns a valid result, the files are on the MATLAB path and you should be able to open and run them successfully.
If not, please add the files to the MATLAB search path; you may need to use the following command to refresh the path before trying to open the files again:
>> addpath(‘C:\ProgramData\MATLAB\SupportPackages\RXXXXy\toolbox\<Toolbox Name>\supportpackages\<Support Package Name>\<examples>’)
>> rehash path
5. In some instances, Support Package examples vary from release to release.
Confirm that the example you are looking for exists in the MATLAB version you are trying to access it from. Refer to the documentation pages for your specific MATLAB version, and confirm that the example appears listed somewhere in the version-specific documentation.
I hope this helps!

More Answers (0)

Community Treasure Hunt

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

Start Hunting!