Tag Archives: matlab
Fints – extract x years historical prices
Hello,
I have a set of historical prices for MSFT for the last 20 years, from 2001 to 2021. To create the timeseries, I’m using "fints"
How should I retrieve the most recent 5 years of data from a time series, knowing that the reference start date is "31/08/2021"?
I tried using the "fetch" function, but this requires knowing the time series’ end date.
Do you have any ideas/suggestions about what function or approach to take in this situation?
Many thanks,
LHello,
I have a set of historical prices for MSFT for the last 20 years, from 2001 to 2021. To create the timeseries, I’m using "fints"
How should I retrieve the most recent 5 years of data from a time series, knowing that the reference start date is "31/08/2021"?
I tried using the "fetch" function, but this requires knowing the time series’ end date.
Do you have any ideas/suggestions about what function or approach to take in this situation?
Many thanks,
L Hello,
I have a set of historical prices for MSFT for the last 20 years, from 2001 to 2021. To create the timeseries, I’m using "fints"
How should I retrieve the most recent 5 years of data from a time series, knowing that the reference start date is "31/08/2021"?
I tried using the "fetch" function, but this requires knowing the time series’ end date.
Do you have any ideas/suggestions about what function or approach to take in this situation?
Many thanks,
L financial timeseries, timeseries, historicalprices, fints, fetch MATLAB Answers — New Questions
How to switch off all 6 MOSFETs (6SO) with ePWM block from C2000 Motor Control Blockset?
Hi,
I’m currently developing a control algorithm for a PMSM.
I’m using the F28379 Launchpad and the BOOSTXL-DRV8305EVM.
To model the algorithm, I’m using the C2000 Microcontroller Blockset in Simulink.
I generate the three dutycycle commands for the three phases and use the ePWM blocks from the C2000 motor control blockset in the following.
For the algorithm I’m also including a safestate, where all 6 switches of the inverter should be switched off.
How can I do this while maintaining the ePWM blocks as "connection" to the hardware?
What command signals do I have to sent to the ePWM block as input to achieve that behavior?
Just requesting a voltage vector with amplitude = 0 in the alpha-beta-system obviously doesn’t work,
since this will lead all 3 highsides switched on or all lowsides being switched on (space vector 0/7).
I tried playing around with the tripzone tab inside the block but so far wasn’t able to get the desired behavior.
Thanks for the help!Hi,
I’m currently developing a control algorithm for a PMSM.
I’m using the F28379 Launchpad and the BOOSTXL-DRV8305EVM.
To model the algorithm, I’m using the C2000 Microcontroller Blockset in Simulink.
I generate the three dutycycle commands for the three phases and use the ePWM blocks from the C2000 motor control blockset in the following.
For the algorithm I’m also including a safestate, where all 6 switches of the inverter should be switched off.
How can I do this while maintaining the ePWM blocks as "connection" to the hardware?
What command signals do I have to sent to the ePWM block as input to achieve that behavior?
Just requesting a voltage vector with amplitude = 0 in the alpha-beta-system obviously doesn’t work,
since this will lead all 3 highsides switched on or all lowsides being switched on (space vector 0/7).
I tried playing around with the tripzone tab inside the block but so far wasn’t able to get the desired behavior.
Thanks for the help! Hi,
I’m currently developing a control algorithm for a PMSM.
I’m using the F28379 Launchpad and the BOOSTXL-DRV8305EVM.
To model the algorithm, I’m using the C2000 Microcontroller Blockset in Simulink.
I generate the three dutycycle commands for the three phases and use the ePWM blocks from the C2000 motor control blockset in the following.
For the algorithm I’m also including a safestate, where all 6 switches of the inverter should be switched off.
How can I do this while maintaining the ePWM blocks as "connection" to the hardware?
What command signals do I have to sent to the ePWM block as input to achieve that behavior?
Just requesting a voltage vector with amplitude = 0 in the alpha-beta-system obviously doesn’t work,
since this will lead all 3 highsides switched on or all lowsides being switched on (space vector 0/7).
I tried playing around with the tripzone tab inside the block but so far wasn’t able to get the desired behavior.
Thanks for the help! simulink, epwm, electric_motor_control MATLAB Answers — New Questions
about high dimension and low sample using PCA
I am using PCA to detect the abnormality in time-series data. Currently I have high dimension and low sample dataset (15*530 data matrix). I am wondering if I can use PCA to obtain the statistic such as T^2 and SPE. I noticed that some articles stated that it is improper to use PCA to obtain the statistics under such case.I am using PCA to detect the abnormality in time-series data. Currently I have high dimension and low sample dataset (15*530 data matrix). I am wondering if I can use PCA to obtain the statistic such as T^2 and SPE. I noticed that some articles stated that it is improper to use PCA to obtain the statistics under such case. I am using PCA to detect the abnormality in time-series data. Currently I have high dimension and low sample dataset (15*530 data matrix). I am wondering if I can use PCA to obtain the statistic such as T^2 and SPE. I noticed that some articles stated that it is improper to use PCA to obtain the statistics under such case. pca MATLAB Answers — New Questions
Python API cannot be built with setup.py in R2021a
I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
The version specified is not a valid version according to PEP 440.
This may not work as expected with newer versions of
setuptools, pip, and PyPI.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ is not valid according to PEP 440.
Please make sure to specify a valid version for your package.
Also note that future releases of setuptools may halt the build process
if an invalid version is given.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated.I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
The version specified is not a valid version according to PEP 440.
This may not work as expected with newer versions of
setuptools, pip, and PyPI.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ is not valid according to PEP 440.
Please make sure to specify a valid version for your package.
Also note that future releases of setuptools may halt the build process
if an invalid version is given.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated. I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
The version specified is not a valid version according to PEP 440.
This may not work as expected with newer versions of
setuptools, pip, and PyPI.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ is not valid according to PEP 440.
Please make sure to specify a valid version for your package.
Also note that future releases of setuptools may halt the build process
if an invalid version is given.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated. python, matlab-engine, setup.py, setuptools MATLAB Answers — New Questions
Hello i need help with this error i am working in LQR control by LMI
A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible);A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible); A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible); lmi lqr MATLAB Answers — New Questions
Save each vector result from a for loop into a matrix
hello i kindly request for assistance. i would like to read 3 files from a file named filenr.lis. this file contains the names of these files that are stored in a directory called wavf. using a for loop, i would like the result of each file read in a matrix, one column per result. These files are not of the same length. See attached files.
Thank youhello i kindly request for assistance. i would like to read 3 files from a file named filenr.lis. this file contains the names of these files that are stored in a directory called wavf. using a for loop, i would like the result of each file read in a matrix, one column per result. These files are not of the same length. See attached files.
Thank you hello i kindly request for assistance. i would like to read 3 files from a file named filenr.lis. this file contains the names of these files that are stored in a directory called wavf. using a for loop, i would like the result of each file read in a matrix, one column per result. These files are not of the same length. See attached files.
Thank you forloop, vector, matrix MATLAB Answers — New Questions
Failed to load MCR
I have an old application that gives me an error when I run it. The error message states: "Could not find version 7.13 of the MCR. Attempting to load mclmcrrt713.dll. Please install the correct version of the MCR." I tried to install this version, but it is no longer available. Any help would be highly appreciated. Thanks!I have an old application that gives me an error when I run it. The error message states: "Could not find version 7.13 of the MCR. Attempting to load mclmcrrt713.dll. Please install the correct version of the MCR." I tried to install this version, but it is no longer available. Any help would be highly appreciated. Thanks! I have an old application that gives me an error when I run it. The error message states: "Could not find version 7.13 of the MCR. Attempting to load mclmcrrt713.dll. Please install the correct version of the MCR." I tried to install this version, but it is no longer available. Any help would be highly appreciated. Thanks! answers MATLAB Answers — New Questions
Automatic Synchronization unit (ASU)
Hi guys, im working on a control system of a microgrid and it requires an automatic synchronization unit. According to the reference paper being used for the model the ASU This unit tests the realization of ideal conditions of synchronization. At the correct instant this unit gives control logic signals to circuit breaker and changeover switches S1 and S2 to select the appropriate configuration of active and reactive power.
The ASU checks the grid voltage and the voltage form the microgrid control output and creates a signal which is sent to switches and breakers to control the operation. I am unsure exactly how this system is implemented and the refference does not specify any detail of the design of the simulink block. I would like some assistance if possible.
Attached are the reference papers which I am reffeering to.https://www.researchgate.net/publication/329075194_Improvement_of_Microgrid_System_Using_Synchronverters
https://www.researchgate.net/publication/323151274_Modeling_analysis_and_design_of_Synchronverters_for_Microgrid_ApplicationsHi guys, im working on a control system of a microgrid and it requires an automatic synchronization unit. According to the reference paper being used for the model the ASU This unit tests the realization of ideal conditions of synchronization. At the correct instant this unit gives control logic signals to circuit breaker and changeover switches S1 and S2 to select the appropriate configuration of active and reactive power.
The ASU checks the grid voltage and the voltage form the microgrid control output and creates a signal which is sent to switches and breakers to control the operation. I am unsure exactly how this system is implemented and the refference does not specify any detail of the design of the simulink block. I would like some assistance if possible.
Attached are the reference papers which I am reffeering to.https://www.researchgate.net/publication/329075194_Improvement_of_Microgrid_System_Using_Synchronverters
https://www.researchgate.net/publication/323151274_Modeling_analysis_and_design_of_Synchronverters_for_Microgrid_Applications Hi guys, im working on a control system of a microgrid and it requires an automatic synchronization unit. According to the reference paper being used for the model the ASU This unit tests the realization of ideal conditions of synchronization. At the correct instant this unit gives control logic signals to circuit breaker and changeover switches S1 and S2 to select the appropriate configuration of active and reactive power.
The ASU checks the grid voltage and the voltage form the microgrid control output and creates a signal which is sent to switches and breakers to control the operation. I am unsure exactly how this system is implemented and the refference does not specify any detail of the design of the simulink block. I would like some assistance if possible.
Attached are the reference papers which I am reffeering to.https://www.researchgate.net/publication/329075194_Improvement_of_Microgrid_System_Using_Synchronverters
https://www.researchgate.net/publication/323151274_Modeling_analysis_and_design_of_Synchronverters_for_Microgrid_Applications simulink, microgrid, grid synchronization, controls MATLAB Answers — New Questions
Problem based on Modal period & Newmark-Beta Method
I’ve generated an MATLAB code based on these pointed problems, such that:
Q: Consider a 2D 3-story shear building model.
1. Form the mass and stiffness matrices for this building model. No damping in needed for this problem.
2. Using trial and errors, select meaningful story mass and stiffness parameters so that the first natural frequency of the building is 1 sec. Consider that the story mass and stiffness values are similar among the three stories; therefore, you need to set only one stiffness and one mass parameter. Use your engineering judgement and explain your logic. Find and plot the mode shapes of the building model.
3. Implement a Newmark-beta algorithm for time integration of the dynamic equilibrium equation. Use a unidirectional earthquake base excitation as input and solve for the acceleration response at the three DOFs. For the earthquake base excitation, use this input file with a sampling frequency of 100 Hz. Plot the time history of absolute acceleration response at each floor.
4. Resample the input signal at 20, 10, and 2 Hz and redo steps 4-5 with integration time step size of 0.05, 0.1, and 0.5 sec, respectively. Compare the results and explain your observations.
MATLAB CODE
—————————————————————————————————————–
clear all;
clc;
close all;
%% INPUT Parameters:
m = 1; % Initial arbitrary mass of each story
k = 1; % Initial arbitrary stiffness of each story
%% Solution-1: Form Mass and Stiffness Matrices
M = m * eye(3); % Mass matrix
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Stiffness matrix
%% Solution-2: Adjust Mass and Stiffness based on target frequency
target_frequency = 1; % Natural Frequency (Hz)
target_omega = 2 * pi * target_frequency; % Angular Frequency (rad/s)
% Adjust stiffness based on the target frequency
k = target_omega^2 * m / 2;
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Updated Stiffness matrix
%% Solution-3: Find and Plot Mode Shapes
[eigVectors, eigValues] = eig(K, M); % Solve eigenvalue problem
omega = sqrt(diag(eigValues)); % Natural frequencies (rad/s)
figure;
for i = 1:3
subplot(3, 1, i);
plot([0 eigVectors(:,i)’], ‘o-‘); % Plot mode shapes
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Story’);
ylabel(‘Displacement’);
end
%% Solution-4: Implement Newmark-beta algorithm for dynamic analysis
% Parameters for Newmark-beta
beta = 1/4;
gamma = 1/2;
% Load earthquake data
data = load(‘CNP100.txt’); % Load earthquake data
dt = 0.01; % Sampling interval for 100 Hz
time = (0:length(data)-1)*dt;
% Initial conditions
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((data(1) * ones(3, 1)) – K*u); % Initial acceleration
% Time integration using Newmark-beta method
u_history = zeros(3, length(time));
a_history = zeros(3, length(time));
a_history(:, 1) = a;
for i = 1:length(time)-1
% Predictors
u_pred = u + (dt * v) + ((dt^2) * (0.5-beta) * a);
v_pred = v + (dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((data(i+1) * ones(3, 1)) – (K * u_pred));
% Correctors
u = u_pred + (beta * (dt^2) * a_new);
v = v_pred + (gamma * dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
%% Solution-5: Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(time, a_history(i, :));
title([‘Absolute Acceleration Response Sampled at 100 Hz at DOF ‘, num2str(i)]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
%% Solution-6: Resample input signal and repeat the analysis
frequencies = [20, 10, 2];
time_steps = [0.05, 0.1, 0.5];
for j = 1:length(frequencies)
new_fs = frequencies(j);
new_dt = 1/new_fs;
new_data = resample(data, new_fs, 100);
new_time = (0:length(new_data)-1)*new_dt;
% Repeat the Newmark-beta integration with new data
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((new_data(1) * ones(3, 1)) – K*u); % Initial acceleration
u_history = zeros(3, length(new_time));
a_history = zeros(3, length(new_time));
a_history(:, 1) = a;
for i = 1:length(new_time)-1
% Predictors
u_pred = u + (new_dt * v) + ((new_dt^2) * (0.5-beta) * a);
v_pred = v + (new_dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((new_data(i+1) * ones(3, 1)) – K * u_pred);
% Correctors
u = u_pred + (beta * (new_dt^2) * a_new);
v = v_pred + (gamma * new_dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
% Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(new_time, a_history(i, :));
title([‘Absolute Acceleration Response at DOF ‘, num2str(i), ‘ (Resampled at ‘, num2str(new_fs), ‘ Hz)’]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
end
——————————————————————————————————————–
I’m getting error in obtaining:
The first modal period as 1 second.
The correct Newmark Beta plots.I’ve generated an MATLAB code based on these pointed problems, such that:
Q: Consider a 2D 3-story shear building model.
1. Form the mass and stiffness matrices for this building model. No damping in needed for this problem.
2. Using trial and errors, select meaningful story mass and stiffness parameters so that the first natural frequency of the building is 1 sec. Consider that the story mass and stiffness values are similar among the three stories; therefore, you need to set only one stiffness and one mass parameter. Use your engineering judgement and explain your logic. Find and plot the mode shapes of the building model.
3. Implement a Newmark-beta algorithm for time integration of the dynamic equilibrium equation. Use a unidirectional earthquake base excitation as input and solve for the acceleration response at the three DOFs. For the earthquake base excitation, use this input file with a sampling frequency of 100 Hz. Plot the time history of absolute acceleration response at each floor.
4. Resample the input signal at 20, 10, and 2 Hz and redo steps 4-5 with integration time step size of 0.05, 0.1, and 0.5 sec, respectively. Compare the results and explain your observations.
MATLAB CODE
—————————————————————————————————————–
clear all;
clc;
close all;
%% INPUT Parameters:
m = 1; % Initial arbitrary mass of each story
k = 1; % Initial arbitrary stiffness of each story
%% Solution-1: Form Mass and Stiffness Matrices
M = m * eye(3); % Mass matrix
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Stiffness matrix
%% Solution-2: Adjust Mass and Stiffness based on target frequency
target_frequency = 1; % Natural Frequency (Hz)
target_omega = 2 * pi * target_frequency; % Angular Frequency (rad/s)
% Adjust stiffness based on the target frequency
k = target_omega^2 * m / 2;
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Updated Stiffness matrix
%% Solution-3: Find and Plot Mode Shapes
[eigVectors, eigValues] = eig(K, M); % Solve eigenvalue problem
omega = sqrt(diag(eigValues)); % Natural frequencies (rad/s)
figure;
for i = 1:3
subplot(3, 1, i);
plot([0 eigVectors(:,i)’], ‘o-‘); % Plot mode shapes
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Story’);
ylabel(‘Displacement’);
end
%% Solution-4: Implement Newmark-beta algorithm for dynamic analysis
% Parameters for Newmark-beta
beta = 1/4;
gamma = 1/2;
% Load earthquake data
data = load(‘CNP100.txt’); % Load earthquake data
dt = 0.01; % Sampling interval for 100 Hz
time = (0:length(data)-1)*dt;
% Initial conditions
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((data(1) * ones(3, 1)) – K*u); % Initial acceleration
% Time integration using Newmark-beta method
u_history = zeros(3, length(time));
a_history = zeros(3, length(time));
a_history(:, 1) = a;
for i = 1:length(time)-1
% Predictors
u_pred = u + (dt * v) + ((dt^2) * (0.5-beta) * a);
v_pred = v + (dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((data(i+1) * ones(3, 1)) – (K * u_pred));
% Correctors
u = u_pred + (beta * (dt^2) * a_new);
v = v_pred + (gamma * dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
%% Solution-5: Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(time, a_history(i, :));
title([‘Absolute Acceleration Response Sampled at 100 Hz at DOF ‘, num2str(i)]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
%% Solution-6: Resample input signal and repeat the analysis
frequencies = [20, 10, 2];
time_steps = [0.05, 0.1, 0.5];
for j = 1:length(frequencies)
new_fs = frequencies(j);
new_dt = 1/new_fs;
new_data = resample(data, new_fs, 100);
new_time = (0:length(new_data)-1)*new_dt;
% Repeat the Newmark-beta integration with new data
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((new_data(1) * ones(3, 1)) – K*u); % Initial acceleration
u_history = zeros(3, length(new_time));
a_history = zeros(3, length(new_time));
a_history(:, 1) = a;
for i = 1:length(new_time)-1
% Predictors
u_pred = u + (new_dt * v) + ((new_dt^2) * (0.5-beta) * a);
v_pred = v + (new_dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((new_data(i+1) * ones(3, 1)) – K * u_pred);
% Correctors
u = u_pred + (beta * (new_dt^2) * a_new);
v = v_pred + (gamma * new_dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
% Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(new_time, a_history(i, :));
title([‘Absolute Acceleration Response at DOF ‘, num2str(i), ‘ (Resampled at ‘, num2str(new_fs), ‘ Hz)’]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
end
——————————————————————————————————————–
I’m getting error in obtaining:
The first modal period as 1 second.
The correct Newmark Beta plots. I’ve generated an MATLAB code based on these pointed problems, such that:
Q: Consider a 2D 3-story shear building model.
1. Form the mass and stiffness matrices for this building model. No damping in needed for this problem.
2. Using trial and errors, select meaningful story mass and stiffness parameters so that the first natural frequency of the building is 1 sec. Consider that the story mass and stiffness values are similar among the three stories; therefore, you need to set only one stiffness and one mass parameter. Use your engineering judgement and explain your logic. Find and plot the mode shapes of the building model.
3. Implement a Newmark-beta algorithm for time integration of the dynamic equilibrium equation. Use a unidirectional earthquake base excitation as input and solve for the acceleration response at the three DOFs. For the earthquake base excitation, use this input file with a sampling frequency of 100 Hz. Plot the time history of absolute acceleration response at each floor.
4. Resample the input signal at 20, 10, and 2 Hz and redo steps 4-5 with integration time step size of 0.05, 0.1, and 0.5 sec, respectively. Compare the results and explain your observations.
MATLAB CODE
—————————————————————————————————————–
clear all;
clc;
close all;
%% INPUT Parameters:
m = 1; % Initial arbitrary mass of each story
k = 1; % Initial arbitrary stiffness of each story
%% Solution-1: Form Mass and Stiffness Matrices
M = m * eye(3); % Mass matrix
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Stiffness matrix
%% Solution-2: Adjust Mass and Stiffness based on target frequency
target_frequency = 1; % Natural Frequency (Hz)
target_omega = 2 * pi * target_frequency; % Angular Frequency (rad/s)
% Adjust stiffness based on the target frequency
k = target_omega^2 * m / 2;
K = [ 2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Updated Stiffness matrix
%% Solution-3: Find and Plot Mode Shapes
[eigVectors, eigValues] = eig(K, M); % Solve eigenvalue problem
omega = sqrt(diag(eigValues)); % Natural frequencies (rad/s)
figure;
for i = 1:3
subplot(3, 1, i);
plot([0 eigVectors(:,i)’], ‘o-‘); % Plot mode shapes
title([‘Mode Shape ‘, num2str(i)]);
xlabel(‘Story’);
ylabel(‘Displacement’);
end
%% Solution-4: Implement Newmark-beta algorithm for dynamic analysis
% Parameters for Newmark-beta
beta = 1/4;
gamma = 1/2;
% Load earthquake data
data = load(‘CNP100.txt’); % Load earthquake data
dt = 0.01; % Sampling interval for 100 Hz
time = (0:length(data)-1)*dt;
% Initial conditions
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((data(1) * ones(3, 1)) – K*u); % Initial acceleration
% Time integration using Newmark-beta method
u_history = zeros(3, length(time));
a_history = zeros(3, length(time));
a_history(:, 1) = a;
for i = 1:length(time)-1
% Predictors
u_pred = u + (dt * v) + ((dt^2) * (0.5-beta) * a);
v_pred = v + (dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((data(i+1) * ones(3, 1)) – (K * u_pred));
% Correctors
u = u_pred + (beta * (dt^2) * a_new);
v = v_pred + (gamma * dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
%% Solution-5: Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(time, a_history(i, :));
title([‘Absolute Acceleration Response Sampled at 100 Hz at DOF ‘, num2str(i)]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
%% Solution-6: Resample input signal and repeat the analysis
frequencies = [20, 10, 2];
time_steps = [0.05, 0.1, 0.5];
for j = 1:length(frequencies)
new_fs = frequencies(j);
new_dt = 1/new_fs;
new_data = resample(data, new_fs, 100);
new_time = (0:length(new_data)-1)*new_dt;
% Repeat the Newmark-beta integration with new data
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M ((new_data(1) * ones(3, 1)) – K*u); % Initial acceleration
u_history = zeros(3, length(new_time));
a_history = zeros(3, length(new_time));
a_history(:, 1) = a;
for i = 1:length(new_time)-1
% Predictors
u_pred = u + (new_dt * v) + ((new_dt^2) * (0.5-beta) * a);
v_pred = v + (new_dt * (1-gamma) * a);
% Solve for acceleration
a_new = M ((new_data(i+1) * ones(3, 1)) – K * u_pred);
% Correctors
u = u_pred + (beta * (new_dt^2) * a_new);
v = v_pred + (gamma * new_dt * a_new);
% Store response
u_history(:, i+1) = u;
a_history(:, i+1) = a_new;
a = a_new;
end
% Plot time history of absolute acceleration response
figure;
for i = 1:3
subplot(3, 1, i);
plot(new_time, a_history(i, :));
title([‘Absolute Acceleration Response at DOF ‘, num2str(i), ‘ (Resampled at ‘, num2str(new_fs), ‘ Hz)’]);
xlabel(‘Time (s)’);
ylabel(‘Acceleration (m/s^2)’);
end
end
——————————————————————————————————————–
I’m getting error in obtaining:
The first modal period as 1 second.
The correct Newmark Beta plots. newmarkbeta, modalperiod, structuraldynamics MATLAB Answers — New Questions
Why do I get this error? com.mathworks.toolbox.javabuilder.internal.MWMCR
I keep on getting this error when trying to run on server.
java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.toolbox.javabuilder.internal.MWMCR
com.mathworks.toolbox.javabuilder.MWUtil.GetUnknownClassID(MWUtil.java:727)
com.mathworks.toolbox.javabuilder.MWClassID.<clinit>(MWClassID.java:41)
SingleDose.doGet(SingleDose.java:63)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51
Can somebody please explain what should I do? I dont have problem to run the .jsp file. The error will come only when I try to simulate the webfigure.
*Work done:* Install SDK, mex -setup, install MCR, putting javabuilder.jar in Tomcat lib, set environment for JAVA_HOME JAVA_JRE CLASSPATH Path CATALINA_HOME.I keep on getting this error when trying to run on server.
java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.toolbox.javabuilder.internal.MWMCR
com.mathworks.toolbox.javabuilder.MWUtil.GetUnknownClassID(MWUtil.java:727)
com.mathworks.toolbox.javabuilder.MWClassID.<clinit>(MWClassID.java:41)
SingleDose.doGet(SingleDose.java:63)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51
Can somebody please explain what should I do? I dont have problem to run the .jsp file. The error will come only when I try to simulate the webfigure.
*Work done:* Install SDK, mex -setup, install MCR, putting javabuilder.jar in Tomcat lib, set environment for JAVA_HOME JAVA_JRE CLASSPATH Path CATALINA_HOME. I keep on getting this error when trying to run on server.
java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.toolbox.javabuilder.internal.MWMCR
com.mathworks.toolbox.javabuilder.MWUtil.GetUnknownClassID(MWUtil.java:727)
com.mathworks.toolbox.javabuilder.MWClassID.<clinit>(MWClassID.java:41)
SingleDose.doGet(SingleDose.java:63)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51
Can somebody please explain what should I do? I dont have problem to run the .jsp file. The error will come only when I try to simulate the webfigure.
*Work done:* Install SDK, mex -setup, install MCR, putting javabuilder.jar in Tomcat lib, set environment for JAVA_HOME JAVA_JRE CLASSPATH Path CATALINA_HOME. java, webfigure MATLAB Answers — New Questions
how to select simulink block through keyboard
hi, i want select the blocks through keyboard, as following fig shows, i want select the lower block, it’s possible or not?hi, i want select the blocks through keyboard, as following fig shows, i want select the lower block, it’s possible or not? hi, i want select the blocks through keyboard, as following fig shows, i want select the lower block, it’s possible or not? select block, keyboard MATLAB Answers — New Questions
Project 3D surface onto 2D plot
Hi all,
I have a set of X,Y,Z data where X and Y represent coordinates and Z the corresponding elevation. How can I now plot a 2D image with the projection of the 3D surface on it?
In stead of:
<<https://www.researchgate.net/profile/M_Hennessey/publication/267491866/figure/fig4/AS:295759909015586@1447526065926/FIGURE-4-LONE-MOUNTAIN-CHARACTERIZED-USING-THE-R-3D-MATLAB-INTERP2-COMMAND-AND-DEM-DATA.png>>
I’d like to have something like this:
<<http://cn.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/19791/versions/2/screenshot.jpg>>
Thanks!Hi all,
I have a set of X,Y,Z data where X and Y represent coordinates and Z the corresponding elevation. How can I now plot a 2D image with the projection of the 3D surface on it?
In stead of:
<<https://www.researchgate.net/profile/M_Hennessey/publication/267491866/figure/fig4/AS:295759909015586@1447526065926/FIGURE-4-LONE-MOUNTAIN-CHARACTERIZED-USING-THE-R-3D-MATLAB-INTERP2-COMMAND-AND-DEM-DATA.png>>
I’d like to have something like this:
<<http://cn.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/19791/versions/2/screenshot.jpg>>
Thanks! Hi all,
I have a set of X,Y,Z data where X and Y represent coordinates and Z the corresponding elevation. How can I now plot a 2D image with the projection of the 3D surface on it?
In stead of:
<<https://www.researchgate.net/profile/M_Hennessey/publication/267491866/figure/fig4/AS:295759909015586@1447526065926/FIGURE-4-LONE-MOUNTAIN-CHARACTERIZED-USING-THE-R-3D-MATLAB-INTERP2-COMMAND-AND-DEM-DATA.png>>
I’d like to have something like this:
<<http://cn.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/19791/versions/2/screenshot.jpg>>
Thanks! matlab, 3d plots MATLAB Answers — New Questions
How to compare between simulink setting file?
How to compare between simulink setting file
visdiff command is not what i wanted..How to compare between simulink setting file
visdiff command is not what i wanted.. How to compare between simulink setting file
visdiff command is not what i wanted.. simulink, compare file MATLAB Answers — New Questions
Webwrite to metadata Thingspeak Channel
Helllo,
I would like to write to the Metadat of my channel but I cna’t get it to work. as a test , I tried wiriting to the Status which works.
if fieldName = "status"; is changed to fieldName = "metadata"; it doesn’t work! does anyone know the trick for getting this to work?
code here:
%keys & ID here …
thingSpeakURL = "http://api.thingspeak.com/";
thingSpeakWriteURL = thingSpeakURL + "update";
fieldName = "status";
fieldValue = ‘[100 100 100 92 93 93 94 ; 55 55 56 57 58 63 64 ; 333 444 555 666 777 888 999]’;
response = webwrite(thingSpeakWriteURL,"api_key",writeApiKey,fieldName,fieldValue);Helllo,
I would like to write to the Metadat of my channel but I cna’t get it to work. as a test , I tried wiriting to the Status which works.
if fieldName = "status"; is changed to fieldName = "metadata"; it doesn’t work! does anyone know the trick for getting this to work?
code here:
%keys & ID here …
thingSpeakURL = "http://api.thingspeak.com/";
thingSpeakWriteURL = thingSpeakURL + "update";
fieldName = "status";
fieldValue = ‘[100 100 100 92 93 93 94 ; 55 55 56 57 58 63 64 ; 333 444 555 666 777 888 999]’;
response = webwrite(thingSpeakWriteURL,"api_key",writeApiKey,fieldName,fieldValue); Helllo,
I would like to write to the Metadat of my channel but I cna’t get it to work. as a test , I tried wiriting to the Status which works.
if fieldName = "status"; is changed to fieldName = "metadata"; it doesn’t work! does anyone know the trick for getting this to work?
code here:
%keys & ID here …
thingSpeakURL = "http://api.thingspeak.com/";
thingSpeakWriteURL = thingSpeakURL + "update";
fieldName = "status";
fieldValue = ‘[100 100 100 92 93 93 94 ; 55 55 56 57 58 63 64 ; 333 444 555 666 777 888 999]’;
response = webwrite(thingSpeakWriteURL,"api_key",writeApiKey,fieldName,fieldValue); webwrite metadata MATLAB Answers — New Questions
Converting a color image into a set of data
Hi, I have a thermal image in png form, with a color scale/map to go with it of a cell. I am just looking to try and converrt the colors to the designated values based on the color scale/map to the different values based on the color map. Then I am looking to create a graph of the color intesnsity verus distance along the cell. I have attached an image of what I am trying to convert, if you have any tips or information that may help that would be greately appreciated.Hi, I have a thermal image in png form, with a color scale/map to go with it of a cell. I am just looking to try and converrt the colors to the designated values based on the color scale/map to the different values based on the color map. Then I am looking to create a graph of the color intesnsity verus distance along the cell. I have attached an image of what I am trying to convert, if you have any tips or information that may help that would be greately appreciated. Hi, I have a thermal image in png form, with a color scale/map to go with it of a cell. I am just looking to try and converrt the colors to the designated values based on the color scale/map to the different values based on the color map. Then I am looking to create a graph of the color intesnsity verus distance along the cell. I have attached an image of what I am trying to convert, if you have any tips or information that may help that would be greately appreciated. image analysis, colormap MATLAB Answers — New Questions
Why do I get ‘An error occurred during writing’ error when writing data to a virtual serial port?
I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it?I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it? I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it? serial, com, rs232, rs-232, fwrite, fprintf MATLAB Answers — New Questions
Why am I unable to use my serial port after a hardware reset if the port was open in MATLAB?
I use USB-devices that create virtual serial ports in Windows, for instance COM5. When MATLAB opens a connection with one of these devices and the device disconnects and reconnects, I am unable to use the device any more. What can I do to regain access to the device?
ERROR: myComPort = serial(‘COM5’);fopen(myComPort);% now disconnect the device
% now connect the device again, the following will be unsuccessful:delete(myComPort)
clear myComPortmyComPort = serial(‘COM5’);fopen(myComPort);Error using serial/fopen (line 72)
Open failed: Port: COM5 is not available. Available ports: COM1, COM3.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.I use USB-devices that create virtual serial ports in Windows, for instance COM5. When MATLAB opens a connection with one of these devices and the device disconnects and reconnects, I am unable to use the device any more. What can I do to regain access to the device?
ERROR: myComPort = serial(‘COM5’);fopen(myComPort);% now disconnect the device
% now connect the device again, the following will be unsuccessful:delete(myComPort)
clear myComPortmyComPort = serial(‘COM5’);fopen(myComPort);Error using serial/fopen (line 72)
Open failed: Port: COM5 is not available. Available ports: COM1, COM3.
Use INSTRFIND to determine if other instrument objects are connected to the requested device. I use USB-devices that create virtual serial ports in Windows, for instance COM5. When MATLAB opens a connection with one of these devices and the device disconnects and reconnects, I am unable to use the device any more. What can I do to regain access to the device?
ERROR: myComPort = serial(‘COM5’);fopen(myComPort);% now disconnect the device
% now connect the device again, the following will be unsuccessful:delete(myComPort)
clear myComPortmyComPort = serial(‘COM5’);fopen(myComPort);Error using serial/fopen (line 72)
Open failed: Port: COM5 is not available. Available ports: COM1, COM3.
Use INSTRFIND to determine if other instrument objects are connected to the requested device. serial, reconnect MATLAB Answers — New Questions
Change a variable string to a normal variable
I need to change a string variable(x="Eval_E01") to a normal variable for example y=Eval_E01.
Is there a instrucction for this?
Thaks in advanceI need to change a string variable(x="Eval_E01") to a normal variable for example y=Eval_E01.
Is there a instrucction for this?
Thaks in advance I need to change a string variable(x="Eval_E01") to a normal variable for example y=Eval_E01.
Is there a instrucction for this?
Thaks in advance string variable, normal variable MATLAB Answers — New Questions
Why do I receive ‘Failed to open serial port COM* to communicate with the board’ or ‘Open fail: Port: COM* is not available. No ports are available.’ error with MATLAB/Simulink support package for Arduino Hardware
Why do I receive the following error when trying to connect to Arduino Hardware with the MATLAB support package?
ERROR: Failed to open serial port COM6 to communicate with board Uno. Make
sure there is no other MATLAB arduino object for this board. For
troubleshooting, see Arduino Hardware Troubleshooting.
Correspondingly using the Simulink Support Package for Arduino, why do I receive the following error when building a model for the Arduino?
ERROR: Open fail: Port: COM* is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.Why do I receive the following error when trying to connect to Arduino Hardware with the MATLAB support package?
ERROR: Failed to open serial port COM6 to communicate with board Uno. Make
sure there is no other MATLAB arduino object for this board. For
troubleshooting, see Arduino Hardware Troubleshooting.
Correspondingly using the Simulink Support Package for Arduino, why do I receive the following error when building a model for the Arduino?
ERROR: Open fail: Port: COM* is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device. Why do I receive the following error when trying to connect to Arduino Hardware with the MATLAB support package?
ERROR: Failed to open serial port COM6 to communicate with board Uno. Make
sure there is no other MATLAB arduino object for this board. For
troubleshooting, see Arduino Hardware Troubleshooting.
Correspondingly using the Simulink Support Package for Arduino, why do I receive the following error when building a model for the Arduino?
ERROR: Open fail: Port: COM* is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device. MATLAB Answers — New Questions
HELPPP -Command Window broken after resetting
I put an input in and then when I restarted my computer the bottom left of my MATLABS online says waiting for input and nothing I put into my command window works. I tried pause, end, ect.. Is there a way to hard reset my command window or the give the input and end it so I can start a different command?? I’m using MATLAB Online.I put an input in and then when I restarted my computer the bottom left of my MATLABS online says waiting for input and nothing I put into my command window works. I tried pause, end, ect.. Is there a way to hard reset my command window or the give the input and end it so I can start a different command?? I’m using MATLAB Online. I put an input in and then when I restarted my computer the bottom left of my MATLABS online says waiting for input and nothing I put into my command window works. I tried pause, end, ect.. Is there a way to hard reset my command window or the give the input and end it so I can start a different command?? I’m using MATLAB Online. waiting for input, command window MATLAB Answers — New Questions