Tag Archives: matlab
Control quiver arrow head width vs height.
Hi, I have a quiver plot where the arrow heads are incredibly wide by default, so I used "MaxHeadSize" to shrink them to a reasonable size. Also, the scaling behavior is set to 0 because I want them to connect the way they do currently. The downside is that now, instead of looking like arrowheads, they almost look like horizontal bars. I’m wondering if there is a way to control the head length independently of the head width.Hi, I have a quiver plot where the arrow heads are incredibly wide by default, so I used "MaxHeadSize" to shrink them to a reasonable size. Also, the scaling behavior is set to 0 because I want them to connect the way they do currently. The downside is that now, instead of looking like arrowheads, they almost look like horizontal bars. I’m wondering if there is a way to control the head length independently of the head width. Hi, I have a quiver plot where the arrow heads are incredibly wide by default, so I used "MaxHeadSize" to shrink them to a reasonable size. Also, the scaling behavior is set to 0 because I want them to connect the way they do currently. The downside is that now, instead of looking like arrowheads, they almost look like horizontal bars. I’m wondering if there is a way to control the head length independently of the head width. quiver, matlab, graph MATLAB Answers — New Questions
How to search array in array same values?
Hello,
I create an array below;
bigArray = rand(1,150);
bigArray(1,15:19) = [1 1 1 1 1]’;
bigArray(1,25:29) = [1 1 1 1 1]’;
bigArray(1,75:79) = [1 1 1 1 1]’;
bigArray(1,105:109) = [1 1 1 1 1]’;
bigArray(1,65) = 1;
bigArray(1,5:6) = [1 1]’;
I want to find [1 1 1 1 1]’ array indexes. But I run the code;
idx = find(ismember(bigArray,[1 1 1 1 1]’))
I want to see as an output; [15 16 17 18 19 25 26 27 28 29 75 76 77 78 79 105 106 107 108 109]Hello,
I create an array below;
bigArray = rand(1,150);
bigArray(1,15:19) = [1 1 1 1 1]’;
bigArray(1,25:29) = [1 1 1 1 1]’;
bigArray(1,75:79) = [1 1 1 1 1]’;
bigArray(1,105:109) = [1 1 1 1 1]’;
bigArray(1,65) = 1;
bigArray(1,5:6) = [1 1]’;
I want to find [1 1 1 1 1]’ array indexes. But I run the code;
idx = find(ismember(bigArray,[1 1 1 1 1]’))
I want to see as an output; [15 16 17 18 19 25 26 27 28 29 75 76 77 78 79 105 106 107 108 109] Hello,
I create an array below;
bigArray = rand(1,150);
bigArray(1,15:19) = [1 1 1 1 1]’;
bigArray(1,25:29) = [1 1 1 1 1]’;
bigArray(1,75:79) = [1 1 1 1 1]’;
bigArray(1,105:109) = [1 1 1 1 1]’;
bigArray(1,65) = 1;
bigArray(1,5:6) = [1 1]’;
I want to find [1 1 1 1 1]’ array indexes. But I run the code;
idx = find(ismember(bigArray,[1 1 1 1 1]’))
I want to see as an output; [15 16 17 18 19 25 26 27 28 29 75 76 77 78 79 105 106 107 108 109] matlab, array, find, indexing MATLAB Answers — New Questions
Create a generic x for (x,y) plot
I’m not well versed in matlab at all so hopefully this post makes some sense.
I have tons of data in .txt files that I want to plot. However the only "x" data set that I have is the real life time which I can’t use in my plot(x,y) command since the numbers are 10:23:55, for example. Since the x-axis is just time,I want to make a generic x dataset with a command with which the x gets the same length as the y data sets. Hopefully someone can help me with thisI’m not well versed in matlab at all so hopefully this post makes some sense.
I have tons of data in .txt files that I want to plot. However the only "x" data set that I have is the real life time which I can’t use in my plot(x,y) command since the numbers are 10:23:55, for example. Since the x-axis is just time,I want to make a generic x dataset with a command with which the x gets the same length as the y data sets. Hopefully someone can help me with this I’m not well versed in matlab at all so hopefully this post makes some sense.
I have tons of data in .txt files that I want to plot. However the only "x" data set that I have is the real life time which I can’t use in my plot(x,y) command since the numbers are 10:23:55, for example. Since the x-axis is just time,I want to make a generic x dataset with a command with which the x gets the same length as the y data sets. Hopefully someone can help me with this plotting MATLAB Answers — New Questions
Simulink Debug brings up two Visual studio sessions
I ran into issues when trying to debug c caller code in simulink. environment: Matlab 2022a, Visual Studio Community 2019.
When Debug-> Add Breakpoint -> set breakpoint in custom code , two sessions of Visual Studio were brough up. The code I was debugging did not show in the module view in one of the sessions, so the breakpoint did not work. The other session has the module loaded , but looks like the thread was not attached to the actual simulation ( even though it showed as attached. )
Anybody has a solution or suggestion ?I ran into issues when trying to debug c caller code in simulink. environment: Matlab 2022a, Visual Studio Community 2019.
When Debug-> Add Breakpoint -> set breakpoint in custom code , two sessions of Visual Studio were brough up. The code I was debugging did not show in the module view in one of the sessions, so the breakpoint did not work. The other session has the module loaded , but looks like the thread was not attached to the actual simulation ( even though it showed as attached. )
Anybody has a solution or suggestion ? I ran into issues when trying to debug c caller code in simulink. environment: Matlab 2022a, Visual Studio Community 2019.
When Debug-> Add Breakpoint -> set breakpoint in custom code , two sessions of Visual Studio were brough up. The code I was debugging did not show in the module view in one of the sessions, so the breakpoint did not work. The other session has the module loaded , but looks like the thread was not attached to the actual simulation ( even though it showed as attached. )
Anybody has a solution or suggestion ? c debug MATLAB Answers — New Questions
Colon operands must be real scalars
I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100);I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100); I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100); colon, array indexing MATLAB Answers — New Questions
Pre-commit on Gitlab with Matlab files
I would like to add a pre-commit check for a Matlab project that is on Gitlab.
Is there a template for the pre-commit-config.yaml ? What are the hooks that would work with Matlab files ?
For example, for avoiding repeated code, formatting the code, making sure that all variables are written in CamelCase, making sure that the names of variables are understandable enough.I would like to add a pre-commit check for a Matlab project that is on Gitlab.
Is there a template for the pre-commit-config.yaml ? What are the hooks that would work with Matlab files ?
For example, for avoiding repeated code, formatting the code, making sure that all variables are written in CamelCase, making sure that the names of variables are understandable enough. I would like to add a pre-commit check for a Matlab project that is on Gitlab.
Is there a template for the pre-commit-config.yaml ? What are the hooks that would work with Matlab files ?
For example, for avoiding repeated code, formatting the code, making sure that all variables are written in CamelCase, making sure that the names of variables are understandable enough. pre-commit, gitlab MATLAB Answers — New Questions
Heatmap doesn’t show the values
The heatmap figures I used to plot on Matlab had the values labeled in each cell (just like the documenation says), but now the figure doesn’t include the text. I’m not sure if I made changes to some settings. Does anyone know what the issue is?
For instance, I get the correct output here, when I run the following on web.
figure
heatmap(magic(5)); colormap(sky)
But this is what I get when I run this locally on my computer.
** EDIT: I run 2024aThe heatmap figures I used to plot on Matlab had the values labeled in each cell (just like the documenation says), but now the figure doesn’t include the text. I’m not sure if I made changes to some settings. Does anyone know what the issue is?
For instance, I get the correct output here, when I run the following on web.
figure
heatmap(magic(5)); colormap(sky)
But this is what I get when I run this locally on my computer.
** EDIT: I run 2024a The heatmap figures I used to plot on Matlab had the values labeled in each cell (just like the documenation says), but now the figure doesn’t include the text. I’m not sure if I made changes to some settings. Does anyone know what the issue is?
For instance, I get the correct output here, when I run the following on web.
figure
heatmap(magic(5)); colormap(sky)
But this is what I get when I run this locally on my computer.
** EDIT: I run 2024a heatmap, labels MATLAB Answers — New Questions
Unable to load product files. Product files must be in the same folder as the input file.
Note: I am trying to install Matlab on the Ubuntu server which doesn’t have desktop.
I can only use Ubuntu terminal.
I downloaded R2022a installer for Linux and unzipped it.
The path of directory was
/home/matlab_R2022a_glnxa64
I modified /home/matlab_R2022a_glnxa64/installer_input.txt
fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx
licensePath=license.lic # I downloaded license file after activating the hostID
agreeToLicense=yes
I typed installation script in the directory: /home/matlab_R2022a_glnxa64
My installation script was
bash install -inputFile installer_input.txt
The log was
(Aug 09, 2022 15:54:07) Session key: xxx-xxx-xxx-…
(Aug 09, 2022 15:54:07) Product Files Folder: /home/matlab_R2022a_glnxa64/archives
(Aug 09, 2022 15:54:07) License Agreement validation is successful.
(Aug 09, 2022 15:54:07) Unable to load product files. Product files must be in the same folder as the input file.
For help getting the product files, see the installation documentation on
<a HREF="https://www.mathworks.com/pi_noprode_mpi_R2022a_glnxa64">MATLAB Answer</a>.
(Aug 09, 2022 15:54:07) Exiting with status -2
(Aug 09, 2022 15:54:07) End – Unsuccessful
In the /home/matlab_R2022a_glnxa64/archives, there are 2 folders
– /home/matlab_R2022a_glnxa64/archives
– common
– Network_License_Manager111621_common.zip
– glnxa64
– Network_License_Manager111621_glnxa64.zip
I couldn’t find any useful solution yet from "MathWorks Support Team".
What is the "product files" in the log and where can I find it?
P.S.
I tried to install with ISO file.
But since the mounted directory of the ISO file was read-only, I could not modify installer_input.txt.
So, I failed with it as well.Note: I am trying to install Matlab on the Ubuntu server which doesn’t have desktop.
I can only use Ubuntu terminal.
I downloaded R2022a installer for Linux and unzipped it.
The path of directory was
/home/matlab_R2022a_glnxa64
I modified /home/matlab_R2022a_glnxa64/installer_input.txt
fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx
licensePath=license.lic # I downloaded license file after activating the hostID
agreeToLicense=yes
I typed installation script in the directory: /home/matlab_R2022a_glnxa64
My installation script was
bash install -inputFile installer_input.txt
The log was
(Aug 09, 2022 15:54:07) Session key: xxx-xxx-xxx-…
(Aug 09, 2022 15:54:07) Product Files Folder: /home/matlab_R2022a_glnxa64/archives
(Aug 09, 2022 15:54:07) License Agreement validation is successful.
(Aug 09, 2022 15:54:07) Unable to load product files. Product files must be in the same folder as the input file.
For help getting the product files, see the installation documentation on
<a HREF="https://www.mathworks.com/pi_noprode_mpi_R2022a_glnxa64">MATLAB Answer</a>.
(Aug 09, 2022 15:54:07) Exiting with status -2
(Aug 09, 2022 15:54:07) End – Unsuccessful
In the /home/matlab_R2022a_glnxa64/archives, there are 2 folders
– /home/matlab_R2022a_glnxa64/archives
– common
– Network_License_Manager111621_common.zip
– glnxa64
– Network_License_Manager111621_glnxa64.zip
I couldn’t find any useful solution yet from "MathWorks Support Team".
What is the "product files" in the log and where can I find it?
P.S.
I tried to install with ISO file.
But since the mounted directory of the ISO file was read-only, I could not modify installer_input.txt.
So, I failed with it as well. Note: I am trying to install Matlab on the Ubuntu server which doesn’t have desktop.
I can only use Ubuntu terminal.
I downloaded R2022a installer for Linux and unzipped it.
The path of directory was
/home/matlab_R2022a_glnxa64
I modified /home/matlab_R2022a_glnxa64/installer_input.txt
fileInstallationKey=xxxxx-xxxxx-xxxxx-xxxxx
licensePath=license.lic # I downloaded license file after activating the hostID
agreeToLicense=yes
I typed installation script in the directory: /home/matlab_R2022a_glnxa64
My installation script was
bash install -inputFile installer_input.txt
The log was
(Aug 09, 2022 15:54:07) Session key: xxx-xxx-xxx-…
(Aug 09, 2022 15:54:07) Product Files Folder: /home/matlab_R2022a_glnxa64/archives
(Aug 09, 2022 15:54:07) License Agreement validation is successful.
(Aug 09, 2022 15:54:07) Unable to load product files. Product files must be in the same folder as the input file.
For help getting the product files, see the installation documentation on
<a HREF="https://www.mathworks.com/pi_noprode_mpi_R2022a_glnxa64">MATLAB Answer</a>.
(Aug 09, 2022 15:54:07) Exiting with status -2
(Aug 09, 2022 15:54:07) End – Unsuccessful
In the /home/matlab_R2022a_glnxa64/archives, there are 2 folders
– /home/matlab_R2022a_glnxa64/archives
– common
– Network_License_Manager111621_common.zip
– glnxa64
– Network_License_Manager111621_glnxa64.zip
I couldn’t find any useful solution yet from "MathWorks Support Team".
What is the "product files" in the log and where can I find it?
P.S.
I tried to install with ISO file.
But since the mounted directory of the ISO file was read-only, I could not modify installer_input.txt.
So, I failed with it as well. installation, product files MATLAB Answers — New Questions
Multiplication of a Sparse Matrix With Diagonal Matrices
I have a sparse m x m square matrix L (which is actually a Laplacian matrix of a large graph) and an m x1 vector d. I want to create a diaognal matrix D whose diagonal is populated with the entries in d and then generate
normL = D * L * D
Currently, I am creating a sparse diaognal matrix as
D = spdiags(d, 0, m, m)
and then I use D * L * D.
I wonder whether there is a more efficient way to do this given that the (i, j)-th elements of normL and L are related by
normL(i, j) = D(i) * D(j) * L(i, j).
Thank you very much.I have a sparse m x m square matrix L (which is actually a Laplacian matrix of a large graph) and an m x1 vector d. I want to create a diaognal matrix D whose diagonal is populated with the entries in d and then generate
normL = D * L * D
Currently, I am creating a sparse diaognal matrix as
D = spdiags(d, 0, m, m)
and then I use D * L * D.
I wonder whether there is a more efficient way to do this given that the (i, j)-th elements of normL and L are related by
normL(i, j) = D(i) * D(j) * L(i, j).
Thank you very much. I have a sparse m x m square matrix L (which is actually a Laplacian matrix of a large graph) and an m x1 vector d. I want to create a diaognal matrix D whose diagonal is populated with the entries in d and then generate
normL = D * L * D
Currently, I am creating a sparse diaognal matrix as
D = spdiags(d, 0, m, m)
and then I use D * L * D.
I wonder whether there is a more efficient way to do this given that the (i, j)-th elements of normL and L are related by
normL(i, j) = D(i) * D(j) * L(i, j).
Thank you very much. sparse diagonal matrix, sparse matrix multiplication MATLAB Answers — New Questions
Using hNRReferenceWaveformGenerator with TDD actual pattern
Hi Matlab,
3GPP UL waveforms when generated from 5G Toolboxes, fill only slots which is defined from 3GPP. we also need special subframe with 4 symbols UL enabled. Let me know if we can fill special subrame when exact UL symbols.
// Matlab outputs :
hNRReferenceWaveformGenerator(ulnrref,bw,scs,dm,ncellid);
G-FR1-A1-5, 100MHz, 30kHz, TDD, 1
ulrefwaveformgen.Config.PUSCH{1, 1}.SymbolAllocation = [0,14]
ulrefwaveformgen.Config.PUSCH{1, 1}.SlotAllocation = [8,9,18,19]
// 3GPP defined TDD pattern.
38.141 : Table 4.9.2.2-1: Configurations of TDD for BS type 1-C and BS type 1-H test models
Field name Value
referenceSubcarrierSpacing (kHz) 15 30 60
Periodicity (ms) for dl-UL-TransmissionPeriodicity 5 5 5
nrofDownlinkSlots 3 7 14
nrofDownlinkSymbols 10 6 12
nrofUplinkSlots 1 2 4
nrofUplinkSymbols 2 4 8Hi Matlab,
3GPP UL waveforms when generated from 5G Toolboxes, fill only slots which is defined from 3GPP. we also need special subframe with 4 symbols UL enabled. Let me know if we can fill special subrame when exact UL symbols.
// Matlab outputs :
hNRReferenceWaveformGenerator(ulnrref,bw,scs,dm,ncellid);
G-FR1-A1-5, 100MHz, 30kHz, TDD, 1
ulrefwaveformgen.Config.PUSCH{1, 1}.SymbolAllocation = [0,14]
ulrefwaveformgen.Config.PUSCH{1, 1}.SlotAllocation = [8,9,18,19]
// 3GPP defined TDD pattern.
38.141 : Table 4.9.2.2-1: Configurations of TDD for BS type 1-C and BS type 1-H test models
Field name Value
referenceSubcarrierSpacing (kHz) 15 30 60
Periodicity (ms) for dl-UL-TransmissionPeriodicity 5 5 5
nrofDownlinkSlots 3 7 14
nrofDownlinkSymbols 10 6 12
nrofUplinkSlots 1 2 4
nrofUplinkSymbols 2 4 8 Hi Matlab,
3GPP UL waveforms when generated from 5G Toolboxes, fill only slots which is defined from 3GPP. we also need special subframe with 4 symbols UL enabled. Let me know if we can fill special subrame when exact UL symbols.
// Matlab outputs :
hNRReferenceWaveformGenerator(ulnrref,bw,scs,dm,ncellid);
G-FR1-A1-5, 100MHz, 30kHz, TDD, 1
ulrefwaveformgen.Config.PUSCH{1, 1}.SymbolAllocation = [0,14]
ulrefwaveformgen.Config.PUSCH{1, 1}.SlotAllocation = [8,9,18,19]
// 3GPP defined TDD pattern.
38.141 : Table 4.9.2.2-1: Configurations of TDD for BS type 1-C and BS type 1-H test models
Field name Value
referenceSubcarrierSpacing (kHz) 15 30 60
Periodicity (ms) for dl-UL-TransmissionPeriodicity 5 5 5
nrofDownlinkSlots 3 7 14
nrofDownlinkSymbols 10 6 12
nrofUplinkSlots 1 2 4
nrofUplinkSymbols 2 4 8 hnrreferencewaveformgenerator MATLAB Answers — New Questions
Import geopolyshape from gdb fails
Hi,
I’m completly new to Matlabs.
I’m trying to load my buildings into the siteviewer, to create a rf propagation in the end.
But I just can’t get my buildings to load. My features are in a esri .gdb an in the coordinate system is WGS_1984.
The features are 3d buildings and are of the type esrie multipatch. The level of detail is only 1, so LOD1 (building blocks without roof).
Code to load:
geo = readgeotable("D:Arbeit3D_Ausleuchtung3D_AusleuchtungDatenDaten_1.gdb", CoordinateSystemType="geographic");
viewer = siteviewer(Buildings=geo, Basemap="topographic");
If I try to load these into the siteviewer I get the following error:
"Error using siteviewer
The coordinates of the input points must be finite values; Inf and NaN are not permitted."
I tried converting the features to kmz an import them, but the error is still the same.
I managed to load the sideviewer with only one feature out of my buildings. So some features are OK, some not to import into sideviewer.
All my features are fine in other gis, like arcgis pro or qgis.
But the one building I can load is floating, I don’t know if this is beacause no terrain moddel is loaded or if there is a property to map them to the ground.
Can anyone help me or give me a hint in the right direction?
thanks, sebastianHi,
I’m completly new to Matlabs.
I’m trying to load my buildings into the siteviewer, to create a rf propagation in the end.
But I just can’t get my buildings to load. My features are in a esri .gdb an in the coordinate system is WGS_1984.
The features are 3d buildings and are of the type esrie multipatch. The level of detail is only 1, so LOD1 (building blocks without roof).
Code to load:
geo = readgeotable("D:Arbeit3D_Ausleuchtung3D_AusleuchtungDatenDaten_1.gdb", CoordinateSystemType="geographic");
viewer = siteviewer(Buildings=geo, Basemap="topographic");
If I try to load these into the siteviewer I get the following error:
"Error using siteviewer
The coordinates of the input points must be finite values; Inf and NaN are not permitted."
I tried converting the features to kmz an import them, but the error is still the same.
I managed to load the sideviewer with only one feature out of my buildings. So some features are OK, some not to import into sideviewer.
All my features are fine in other gis, like arcgis pro or qgis.
But the one building I can load is floating, I don’t know if this is beacause no terrain moddel is loaded or if there is a property to map them to the ground.
Can anyone help me or give me a hint in the right direction?
thanks, sebastian Hi,
I’m completly new to Matlabs.
I’m trying to load my buildings into the siteviewer, to create a rf propagation in the end.
But I just can’t get my buildings to load. My features are in a esri .gdb an in the coordinate system is WGS_1984.
The features are 3d buildings and are of the type esrie multipatch. The level of detail is only 1, so LOD1 (building blocks without roof).
Code to load:
geo = readgeotable("D:Arbeit3D_Ausleuchtung3D_AusleuchtungDatenDaten_1.gdb", CoordinateSystemType="geographic");
viewer = siteviewer(Buildings=geo, Basemap="topographic");
If I try to load these into the siteviewer I get the following error:
"Error using siteviewer
The coordinates of the input points must be finite values; Inf and NaN are not permitted."
I tried converting the features to kmz an import them, but the error is still the same.
I managed to load the sideviewer with only one feature out of my buildings. So some features are OK, some not to import into sideviewer.
All my features are fine in other gis, like arcgis pro or qgis.
But the one building I can load is floating, I don’t know if this is beacause no terrain moddel is loaded or if there is a property to map them to the ground.
Can anyone help me or give me a hint in the right direction?
thanks, sebastian geo, geopolyshape, antenna, gdb, readgeotable MATLAB Answers — New Questions
atan2 does not accept complex numbers as input
Good Morning
If I’m not mistaken I think that there is a definition of the atan2() function also in the complex field.
If so , It is possible to implement a complex version of the atan2() function ?
i mean in a way that i can compute atan2(a+i*b , c+i*d) , where a,b,c,d are real and i =sqrt(-1) ,
this both numerically and symbolically
thankyou 🙂
Kind regards
Manu1965@wail.chGood Morning
If I’m not mistaken I think that there is a definition of the atan2() function also in the complex field.
If so , It is possible to implement a complex version of the atan2() function ?
i mean in a way that i can compute atan2(a+i*b , c+i*d) , where a,b,c,d are real and i =sqrt(-1) ,
this both numerically and symbolically
thankyou 🙂
Kind regards
Manu1965@wail.ch Good Morning
If I’m not mistaken I think that there is a definition of the atan2() function also in the complex field.
If so , It is possible to implement a complex version of the atan2() function ?
i mean in a way that i can compute atan2(a+i*b , c+i*d) , where a,b,c,d are real and i =sqrt(-1) ,
this both numerically and symbolically
thankyou 🙂
Kind regards
Manu1965@wail.ch atan2() complex version MATLAB Answers — New Questions
Sending information to MATLAB from Python via TCP
I want to send data from Python to MATLAB every 10 seconds via TCP. The code I have works for the first iteration of the loop, but on the second iteration we reestablish the connection, yet the data fails to send.
The relevant Python code is:
import socket
import sys
import time
%Create a TCP/IP socket
i = 0 %loop counter
j=45.395 %data to be sent to MATLAB
while i < 1000:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((‘localhost’, 51001))
s.listen(1)
conn, addr = s.accept()
print(f"Connected by {addr}")
conn.sendall(bytes(str(j), ‘ASCII’))
conn.close()
i+=1
j+=0.6
time.sleep(10)
The MATLAB code is
i=0;
while i < 1000
t = tcpclient(‘localhost’, 51001);
output = read(t);
data = char(output(1:4));
pwrcmd = str2double(data);
fprintf(‘%f’, pwrcmd);
clear t;
i = i+1;
pause(10)
end
and finally the output on the terminal is:
>python matlab_connect_test.py
Connected by (‘127.0.0.1’, 56010)
Connected by (‘127.0.0.1’, 56012)
The first thing I tried was to establish just one server-client connection, and send data every 10 seconds through that one connection, rather than reconnecting every 10 seconds. That was unsuccessful. For some reason even though the second connection is established, MATLAB never receives the second value of j, or any subsequent values. Any help would be very much appreciated.I want to send data from Python to MATLAB every 10 seconds via TCP. The code I have works for the first iteration of the loop, but on the second iteration we reestablish the connection, yet the data fails to send.
The relevant Python code is:
import socket
import sys
import time
%Create a TCP/IP socket
i = 0 %loop counter
j=45.395 %data to be sent to MATLAB
while i < 1000:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((‘localhost’, 51001))
s.listen(1)
conn, addr = s.accept()
print(f"Connected by {addr}")
conn.sendall(bytes(str(j), ‘ASCII’))
conn.close()
i+=1
j+=0.6
time.sleep(10)
The MATLAB code is
i=0;
while i < 1000
t = tcpclient(‘localhost’, 51001);
output = read(t);
data = char(output(1:4));
pwrcmd = str2double(data);
fprintf(‘%f’, pwrcmd);
clear t;
i = i+1;
pause(10)
end
and finally the output on the terminal is:
>python matlab_connect_test.py
Connected by (‘127.0.0.1’, 56010)
Connected by (‘127.0.0.1’, 56012)
The first thing I tried was to establish just one server-client connection, and send data every 10 seconds through that one connection, rather than reconnecting every 10 seconds. That was unsuccessful. For some reason even though the second connection is established, MATLAB never receives the second value of j, or any subsequent values. Any help would be very much appreciated. I want to send data from Python to MATLAB every 10 seconds via TCP. The code I have works for the first iteration of the loop, but on the second iteration we reestablish the connection, yet the data fails to send.
The relevant Python code is:
import socket
import sys
import time
%Create a TCP/IP socket
i = 0 %loop counter
j=45.395 %data to be sent to MATLAB
while i < 1000:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((‘localhost’, 51001))
s.listen(1)
conn, addr = s.accept()
print(f"Connected by {addr}")
conn.sendall(bytes(str(j), ‘ASCII’))
conn.close()
i+=1
j+=0.6
time.sleep(10)
The MATLAB code is
i=0;
while i < 1000
t = tcpclient(‘localhost’, 51001);
output = read(t);
data = char(output(1:4));
pwrcmd = str2double(data);
fprintf(‘%f’, pwrcmd);
clear t;
i = i+1;
pause(10)
end
and finally the output on the terminal is:
>python matlab_connect_test.py
Connected by (‘127.0.0.1’, 56010)
Connected by (‘127.0.0.1’, 56012)
The first thing I tried was to establish just one server-client connection, and send data every 10 seconds through that one connection, rather than reconnecting every 10 seconds. That was unsuccessful. For some reason even though the second connection is established, MATLAB never receives the second value of j, or any subsequent values. Any help would be very much appreciated. python, matlab, tcp, tcpclient, server MATLAB Answers — New Questions
Dear all, may I know how can we enter the extinction coefficient value in Stk?
I’m using STK system tool kit with matlab and in the laser environment we can use Beer-Lambert law by adding the extinction coefficient so suppose we have a cloud causing attenuation equals 1.2dB/km,how can I enter this value in the extinction field field in Stk, it has to be in m-1 and I have to identify the layer top.I’m using STK system tool kit with matlab and in the laser environment we can use Beer-Lambert law by adding the extinction coefficient so suppose we have a cloud causing attenuation equals 1.2dB/km,how can I enter this value in the extinction field field in Stk, it has to be in m-1 and I have to identify the layer top. I’m using STK system tool kit with matlab and in the laser environment we can use Beer-Lambert law by adding the extinction coefficient so suppose we have a cloud causing attenuation equals 1.2dB/km,how can I enter this value in the extinction field field in Stk, it has to be in m-1 and I have to identify the layer top. attenuation, cloud MATLAB Answers — New Questions
Data type conversion in simulink
Hi, One of the output of simulink model is complex number represented in fixd point 18 word lenght and 14 fractional length which is then converted into 18 word length and 15 fractional length . how i can convert the real part and imaginary part of complex number into hex number ? in simulinkHi, One of the output of simulink model is complex number represented in fixd point 18 word lenght and 14 fractional length which is then converted into 18 word length and 15 fractional length . how i can convert the real part and imaginary part of complex number into hex number ? in simulink Hi, One of the output of simulink model is complex number represented in fixd point 18 word lenght and 14 fractional length which is then converted into 18 word length and 15 fractional length . how i can convert the real part and imaginary part of complex number into hex number ? in simulink simulink, data type conversion MATLAB Answers — New Questions
When trying to use TCST package for matlab getting this error in MATLAb 2024a “Caught “std::exception” Exception message is: Invalid character code sequence detected.”
I am trying to use TCSTInterface to run and optimize some structures in CST MWS. When I try to open and run any CST file from MATLAB 2024a, the program throws me the error:
Caught "std::exception" Exception message is:
Invalid character code sequence detected.
This error is not observed on an older matlab version.
Kindly help.I am trying to use TCSTInterface to run and optimize some structures in CST MWS. When I try to open and run any CST file from MATLAB 2024a, the program throws me the error:
Caught "std::exception" Exception message is:
Invalid character code sequence detected.
This error is not observed on an older matlab version.
Kindly help. I am trying to use TCSTInterface to run and optimize some structures in CST MWS. When I try to open and run any CST file from MATLAB 2024a, the program throws me the error:
Caught "std::exception" Exception message is:
Invalid character code sequence detected.
This error is not observed on an older matlab version.
Kindly help. matlab MATLAB Answers — New Questions
sometimes in the MATLAB command line window, it will occur ” Caught “std::exception” Exception message is: Invalid character code sequence detected.”
sometimes in the MATLAB command line window, it will occur " Caught "std::exception" Exception message is: Invalid character code sequence detected."sometimes in the MATLAB command line window, it will occur " Caught "std::exception" Exception message is: Invalid character code sequence detected." sometimes in the MATLAB command line window, it will occur " Caught "std::exception" Exception message is: Invalid character code sequence detected." bug, matlab, character coed MATLAB Answers — New Questions
how can i change class properties
i change properties of class in addon functions then i got error here is error code.
user defined classes are not supported
in your version of MATLAB
what should i do?
my matlab version is newest and it is for student.
sorry for my bad englishi change properties of class in addon functions then i got error here is error code.
user defined classes are not supported
in your version of MATLAB
what should i do?
my matlab version is newest and it is for student.
sorry for my bad english i change properties of class in addon functions then i got error here is error code.
user defined classes are not supported
in your version of MATLAB
what should i do?
my matlab version is newest and it is for student.
sorry for my bad english change properties MATLAB Answers — New Questions
I am getting an exception running C++ code generated by MATLAB Coder
The code that is failing is captured in the screen shot. Its an error occurring during a malloc() within the function emxInit_real_T().
<</matlabcentral/answers/uploaded_files/116064/exception1.PNG>>
void emxInit_real_T(emxArray_real_T **pEmxArray, int numDimensions)
{
emxArray_real_T *emxArray;
int i;
*pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
emxArray = *pEmxArray;
emxArray->data = (double *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = true;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
}The code that is failing is captured in the screen shot. Its an error occurring during a malloc() within the function emxInit_real_T().
<</matlabcentral/answers/uploaded_files/116064/exception1.PNG>>
void emxInit_real_T(emxArray_real_T **pEmxArray, int numDimensions)
{
emxArray_real_T *emxArray;
int i;
*pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
emxArray = *pEmxArray;
emxArray->data = (double *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = true;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
} The code that is failing is captured in the screen shot. Its an error occurring during a malloc() within the function emxInit_real_T().
<</matlabcentral/answers/uploaded_files/116064/exception1.PNG>>
void emxInit_real_T(emxArray_real_T **pEmxArray, int numDimensions)
{
emxArray_real_T *emxArray;
int i;
*pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
emxArray = *pEmxArray;
emxArray->data = (double *)NULL;
emxArray->numDimensions = numDimensions;
emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
emxArray->allocatedSize = 0;
emxArray->canFreeData = true;
for (i = 0; i < numDimensions; i++) {
emxArray->size[i] = 0;
}
} coder, exception MATLAB Answers — New Questions
Aspen Plus & Matlab (command to deactivate/activate a transfer block?)
Hi everyone,
I have a model in Aspen Plus that I launch with Matlab to vary some parameters.
I want to deactivate a block and then re-activate it (because it helps to reach the convergence).
How can I do that?(which is the code)
Do you know where I can find a list of useful commands for Matlab-Aspen?
Thank you very much.Hi everyone,
I have a model in Aspen Plus that I launch with Matlab to vary some parameters.
I want to deactivate a block and then re-activate it (because it helps to reach the convergence).
How can I do that?(which is the code)
Do you know where I can find a list of useful commands for Matlab-Aspen?
Thank you very much. Hi everyone,
I have a model in Aspen Plus that I launch with Matlab to vary some parameters.
I want to deactivate a block and then re-activate it (because it helps to reach the convergence).
How can I do that?(which is the code)
Do you know where I can find a list of useful commands for Matlab-Aspen?
Thank you very much. aspen plus, deactivate block MATLAB Answers — New Questions