Category: Matlab
Category Archives: Matlab
FM broadcasting Transmitter and Receiver using Adalm Pluto
I am new to SDR and communication systems and I am trying to transmit an mp3 file via FM broadcasting transmitter and then receive it using adalm Pluto. I have connected the Transmitter and receiver together with the cable but when i receive the signal and demodulate it, I only get noise.
This is the block diagram I am using.
And These are my parameters for each block
Thank youI am new to SDR and communication systems and I am trying to transmit an mp3 file via FM broadcasting transmitter and then receive it using adalm Pluto. I have connected the Transmitter and receiver together with the cable but when i receive the signal and demodulate it, I only get noise.
This is the block diagram I am using.
And These are my parameters for each block
Thank you I am new to SDR and communication systems and I am trying to transmit an mp3 file via FM broadcasting transmitter and then receive it using adalm Pluto. I have connected the Transmitter and receiver together with the cable but when i receive the signal and demodulate it, I only get noise.
This is the block diagram I am using.
And These are my parameters for each block
Thank you pluto, fm broadcasting MATLAB Answers — New Questions
How can I apply data in function?
wanna show data in function as val = ~ How can I do this….wanna show data in function as val = ~ How can I do this…. wanna show data in function as val = ~ How can I do this…. #matlab MATLAB Answers — New Questions
Read a userid file and search for userid.json in directory and then search json file
I know what I need to do, just having a hard to getting it going.
I have this userid.txt file that contains the only user files that I want to consider. If the userid say, 1821407, matches a json file within the directory, for example 1821407.json (all json files have this format), I want to check in the file for some data. I’m thinking I can do the search within the json file part. How do I use Matlab to perform the userid comparison within the directory?I know what I need to do, just having a hard to getting it going.
I have this userid.txt file that contains the only user files that I want to consider. If the userid say, 1821407, matches a json file within the directory, for example 1821407.json (all json files have this format), I want to check in the file for some data. I’m thinking I can do the search within the json file part. How do I use Matlab to perform the userid comparison within the directory? I know what I need to do, just having a hard to getting it going.
I have this userid.txt file that contains the only user files that I want to consider. If the userid say, 1821407, matches a json file within the directory, for example 1821407.json (all json files have this format), I want to check in the file for some data. I’m thinking I can do the search within the json file part. How do I use Matlab to perform the userid comparison within the directory? directory search, json files MATLAB Answers — New Questions
Struct array with differently sized fields as parameter data for Simulink simulation
I have CAD files of 3D shapes in obj format. In this format, the shapes are made up of a number of triangles. Using a MATLAB function, I can import data of these shapes into MATLAB. The data are made up of the coordinates of the triangles’ vertices, the vector of the triangles’ surface normals and the triangles’ area. Using the function on one of the files looks like this:
[vertices, surfaceNormals, areas] = objImport(‘some3dShape.obj’);
Now, vertices is a double array of size 3x3xN. N is the number of triangles of this shape and there are three vertices per triangle and each vertex is described by three coordinates. Consequently, surfaceNormals is of size 3xN and areas is of size 1xN.
I want to use these data of multiple shapes in a Simulink simulation. So, I thought, that I could store the data of all shapes nicely in a struct array in the MATLAB workspace before starting the simulation.
shapes = struct();
[shapes(1).vertices, shapes(1).surfaceNormals, shapes(1).areas] = objImport(‘shape1.obj’);
[shapes(2).vertices, shapes(2).surfaceNormals, shapes(2).areas] = objImport(‘shape2.obj’);
[shapes(3).vertices, shapes(3).surfaceNormals, shapes(3).areas] = objImport(‘shape3.obj’);
A MATLAB function block within the Simulink simulation could then access the shapes struct array from the MATLAB workspace as parameter data.
At least, that was the idea. MATLAB can deal with this kind of struct array. However, Simulink throws the error message "Mixed field types in structure arrays are not supported". This only works if all fields with the same name in the struct array have the same size. So, if shapes(1).vertices had size 3x3x100, then shapes(2).vertices would also have to have this size, meaning all shapes must be made up of the same number of triangles.
I am assuming that this error is the same one as described here. So, I am assuming this has to do with the compilation of the simulation into C code.
Possible Solutions I came up with
Create a new struct for every shape (shape1, shape2, …).
Pad the smaller arrays with zeros and add another field that keeps track of the actual amount of triangles per shape.
Solution 1 has the drawback that I would have to adapt my simulation every time I use a different number of shapes. I wanted to use the struct array so that the MATLAB function block can simply iterate over all struct array items in order to keep the simulation as generic as possible.
Solution 2 seems inefficient. If one of the shapes has a lot of triangles, then the struct array items of the other shapes would also have use up the same amount of memory even if they actually had a lot less triangles.
Are there any other solutions? Is there maybe some pointer-based alternative to struct arrays that does not store the actual data but just a pointer to it? That way the fields would all have the same size (that of a pointer).I have CAD files of 3D shapes in obj format. In this format, the shapes are made up of a number of triangles. Using a MATLAB function, I can import data of these shapes into MATLAB. The data are made up of the coordinates of the triangles’ vertices, the vector of the triangles’ surface normals and the triangles’ area. Using the function on one of the files looks like this:
[vertices, surfaceNormals, areas] = objImport(‘some3dShape.obj’);
Now, vertices is a double array of size 3x3xN. N is the number of triangles of this shape and there are three vertices per triangle and each vertex is described by three coordinates. Consequently, surfaceNormals is of size 3xN and areas is of size 1xN.
I want to use these data of multiple shapes in a Simulink simulation. So, I thought, that I could store the data of all shapes nicely in a struct array in the MATLAB workspace before starting the simulation.
shapes = struct();
[shapes(1).vertices, shapes(1).surfaceNormals, shapes(1).areas] = objImport(‘shape1.obj’);
[shapes(2).vertices, shapes(2).surfaceNormals, shapes(2).areas] = objImport(‘shape2.obj’);
[shapes(3).vertices, shapes(3).surfaceNormals, shapes(3).areas] = objImport(‘shape3.obj’);
A MATLAB function block within the Simulink simulation could then access the shapes struct array from the MATLAB workspace as parameter data.
At least, that was the idea. MATLAB can deal with this kind of struct array. However, Simulink throws the error message "Mixed field types in structure arrays are not supported". This only works if all fields with the same name in the struct array have the same size. So, if shapes(1).vertices had size 3x3x100, then shapes(2).vertices would also have to have this size, meaning all shapes must be made up of the same number of triangles.
I am assuming that this error is the same one as described here. So, I am assuming this has to do with the compilation of the simulation into C code.
Possible Solutions I came up with
Create a new struct for every shape (shape1, shape2, …).
Pad the smaller arrays with zeros and add another field that keeps track of the actual amount of triangles per shape.
Solution 1 has the drawback that I would have to adapt my simulation every time I use a different number of shapes. I wanted to use the struct array so that the MATLAB function block can simply iterate over all struct array items in order to keep the simulation as generic as possible.
Solution 2 seems inefficient. If one of the shapes has a lot of triangles, then the struct array items of the other shapes would also have use up the same amount of memory even if they actually had a lot less triangles.
Are there any other solutions? Is there maybe some pointer-based alternative to struct arrays that does not store the actual data but just a pointer to it? That way the fields would all have the same size (that of a pointer). I have CAD files of 3D shapes in obj format. In this format, the shapes are made up of a number of triangles. Using a MATLAB function, I can import data of these shapes into MATLAB. The data are made up of the coordinates of the triangles’ vertices, the vector of the triangles’ surface normals and the triangles’ area. Using the function on one of the files looks like this:
[vertices, surfaceNormals, areas] = objImport(‘some3dShape.obj’);
Now, vertices is a double array of size 3x3xN. N is the number of triangles of this shape and there are three vertices per triangle and each vertex is described by three coordinates. Consequently, surfaceNormals is of size 3xN and areas is of size 1xN.
I want to use these data of multiple shapes in a Simulink simulation. So, I thought, that I could store the data of all shapes nicely in a struct array in the MATLAB workspace before starting the simulation.
shapes = struct();
[shapes(1).vertices, shapes(1).surfaceNormals, shapes(1).areas] = objImport(‘shape1.obj’);
[shapes(2).vertices, shapes(2).surfaceNormals, shapes(2).areas] = objImport(‘shape2.obj’);
[shapes(3).vertices, shapes(3).surfaceNormals, shapes(3).areas] = objImport(‘shape3.obj’);
A MATLAB function block within the Simulink simulation could then access the shapes struct array from the MATLAB workspace as parameter data.
At least, that was the idea. MATLAB can deal with this kind of struct array. However, Simulink throws the error message "Mixed field types in structure arrays are not supported". This only works if all fields with the same name in the struct array have the same size. So, if shapes(1).vertices had size 3x3x100, then shapes(2).vertices would also have to have this size, meaning all shapes must be made up of the same number of triangles.
I am assuming that this error is the same one as described here. So, I am assuming this has to do with the compilation of the simulation into C code.
Possible Solutions I came up with
Create a new struct for every shape (shape1, shape2, …).
Pad the smaller arrays with zeros and add another field that keeps track of the actual amount of triangles per shape.
Solution 1 has the drawback that I would have to adapt my simulation every time I use a different number of shapes. I wanted to use the struct array so that the MATLAB function block can simply iterate over all struct array items in order to keep the simulation as generic as possible.
Solution 2 seems inefficient. If one of the shapes has a lot of triangles, then the struct array items of the other shapes would also have use up the same amount of memory even if they actually had a lot less triangles.
Are there any other solutions? Is there maybe some pointer-based alternative to struct arrays that does not store the actual data but just a pointer to it? That way the fields would all have the same size (that of a pointer). simulink, struct MATLAB Answers — New Questions
How to save an image without axis or white space?
I am currently trying to save an image adn then reopen that image in MATLAB. I am running into an issue that when I save that image it is saving with the axis. This then causes me to reopen the image and have the image be a different diemnsion due to the axis saving. I have then turned off the axis as peopel have recommended from readings other comments on similar problems. However, when I turn off the axis, then the space where the axis used to be saves as white space on my image. I want to open the image and save the image as the same size. I have attached a few pictures of what the image saving looks like. I have attahced the orgional image called square, the working image which is the image without after saved and reopened in MATLAB, and then the same thing hapening wiht the axis which is the screen shot.
Attached below is also my current code for this section of my code.
set(gca, ‘Visible’, ‘off’);
saveas(gcf,’working_image.jpg’);
close all
img = imread(‘working_image.jpg’); % Replace with your image fileI am currently trying to save an image adn then reopen that image in MATLAB. I am running into an issue that when I save that image it is saving with the axis. This then causes me to reopen the image and have the image be a different diemnsion due to the axis saving. I have then turned off the axis as peopel have recommended from readings other comments on similar problems. However, when I turn off the axis, then the space where the axis used to be saves as white space on my image. I want to open the image and save the image as the same size. I have attached a few pictures of what the image saving looks like. I have attahced the orgional image called square, the working image which is the image without after saved and reopened in MATLAB, and then the same thing hapening wiht the axis which is the screen shot.
Attached below is also my current code for this section of my code.
set(gca, ‘Visible’, ‘off’);
saveas(gcf,’working_image.jpg’);
close all
img = imread(‘working_image.jpg’); % Replace with your image file I am currently trying to save an image adn then reopen that image in MATLAB. I am running into an issue that when I save that image it is saving with the axis. This then causes me to reopen the image and have the image be a different diemnsion due to the axis saving. I have then turned off the axis as peopel have recommended from readings other comments on similar problems. However, when I turn off the axis, then the space where the axis used to be saves as white space on my image. I want to open the image and save the image as the same size. I have attached a few pictures of what the image saving looks like. I have attahced the orgional image called square, the working image which is the image without after saved and reopened in MATLAB, and then the same thing hapening wiht the axis which is the screen shot.
Attached below is also my current code for this section of my code.
set(gca, ‘Visible’, ‘off’);
saveas(gcf,’working_image.jpg’);
close all
img = imread(‘working_image.jpg’); % Replace with your image file opening image, saving image MATLAB Answers — New Questions
How can I download the installer for a previous update of MATLAB?
How can I download the installer for a previous update of MATLAB?How can I download the installer for a previous update of MATLAB? How can I download the installer for a previous update of MATLAB? MATLAB Answers — New Questions
Solver configuration error concerning an algebraic loop in double fed induction machine control model.
Good evening.
I am modelling a double fed induction machine in simulink, using simscape for physical components such as stator and rotor sources as well as the DFIG, and simulink for the control block. However when I run the program it gives the following error I show below concerning de Solver Confguration. Any ideas on how to solve it?
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
And many more but I guess the main problem is here.
Thanks in advance.Good evening.
I am modelling a double fed induction machine in simulink, using simscape for physical components such as stator and rotor sources as well as the DFIG, and simulink for the control block. However when I run the program it gives the following error I show below concerning de Solver Confguration. Any ideas on how to solve it?
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
And many more but I guess the main problem is here.
Thanks in advance. Good evening.
I am modelling a double fed induction machine in simulink, using simscape for physical components such as stator and rotor sources as well as the DFIG, and simulink for the control block. However when I run the program it gives the following error I show below concerning de Solver Confguration. Any ideas on how to solve it?
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
Error:’dfig_control_rotor/Solver Configuration’ or the model referenced by it contains a block that updates persistent or state variables while computing outputs and is not supported in an algebraic loop. It is in an algebraic loop with the following blocks.
And many more but I guess the main problem is here.
Thanks in advance. simulink, simscape, loop, error MATLAB Answers — New Questions
Subs Result Still Has Symbolic Variable In It
So as you can see from the result from the console, I am attempting to substitute all the symbolic variables in the symbolic expression tauB(1) with values. But the result of this substitution still has one of the symbolic variables that I substituted for in it? Not sure why this is or how to fix it. tauB(1) is a bit of a length expression but I’ll post it here anyway.
>> tauB(1)
ans =
– (4115149222386437697*rpm1^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm1^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm1^3)/24178516392292583494123520000000 + (10349500888931238881*rpm1^2)/737869762948382064640000000 – (29738775089977568461*rpm1)/360287970189639680000000 + (4115149222386437697*rpm2^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm2^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm2^3)/24178516392292583494123520000000 – (10349500888931238881*rpm2^2)/737869762948382064640000000 + (29738775089977568461*rpm2)/360287970189639680000000 + (4115149222386437697*rpm3^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm3^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm3^3)/24178516392292583494123520000000 – (10349500888931238881*rpm3^2)/737869762948382064640000000 + (29738775089977568461*rpm3)/360287970189639680000000 – (4115149222386437697*rpm4^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm4^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm4^3)/24178516392292583494123520000000 + (10349500888931238881*rpm4^2)/737869762948382064640000000 – (29738775089977568461*rpm4)/360287970189639680000000 + w_kp
Any idea how to fix the subs command to get it to truly substitute for all symbolic vars?So as you can see from the result from the console, I am attempting to substitute all the symbolic variables in the symbolic expression tauB(1) with values. But the result of this substitution still has one of the symbolic variables that I substituted for in it? Not sure why this is or how to fix it. tauB(1) is a bit of a length expression but I’ll post it here anyway.
>> tauB(1)
ans =
– (4115149222386437697*rpm1^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm1^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm1^3)/24178516392292583494123520000000 + (10349500888931238881*rpm1^2)/737869762948382064640000000 – (29738775089977568461*rpm1)/360287970189639680000000 + (4115149222386437697*rpm2^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm2^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm2^3)/24178516392292583494123520000000 – (10349500888931238881*rpm2^2)/737869762948382064640000000 + (29738775089977568461*rpm2)/360287970189639680000000 + (4115149222386437697*rpm3^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm3^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm3^3)/24178516392292583494123520000000 – (10349500888931238881*rpm3^2)/737869762948382064640000000 + (29738775089977568461*rpm3)/360287970189639680000000 – (4115149222386437697*rpm4^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm4^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm4^3)/24178516392292583494123520000000 + (10349500888931238881*rpm4^2)/737869762948382064640000000 – (29738775089977568461*rpm4)/360287970189639680000000 + w_kp
Any idea how to fix the subs command to get it to truly substitute for all symbolic vars? So as you can see from the result from the console, I am attempting to substitute all the symbolic variables in the symbolic expression tauB(1) with values. But the result of this substitution still has one of the symbolic variables that I substituted for in it? Not sure why this is or how to fix it. tauB(1) is a bit of a length expression but I’ll post it here anyway.
>> tauB(1)
ans =
– (4115149222386437697*rpm1^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm1^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm1^3)/24178516392292583494123520000000 + (10349500888931238881*rpm1^2)/737869762948382064640000000 – (29738775089977568461*rpm1)/360287970189639680000000 + (4115149222386437697*rpm2^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm2^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm2^3)/24178516392292583494123520000000 – (10349500888931238881*rpm2^2)/737869762948382064640000000 + (29738775089977568461*rpm2)/360287970189639680000000 + (4115149222386437697*rpm3^5)/12980742146337069071326240823050240000000 – (21808513960237945171*rpm3^4)/792281625142643375935439503360000000 + (21217777204886075429*rpm3^3)/24178516392292583494123520000000 – (10349500888931238881*rpm3^2)/737869762948382064640000000 + (29738775089977568461*rpm3)/360287970189639680000000 – (4115149222386437697*rpm4^5)/12980742146337069071326240823050240000000 + (21808513960237945171*rpm4^4)/792281625142643375935439503360000000 – (21217777204886075429*rpm4^3)/24178516392292583494123520000000 + (10349500888931238881*rpm4^2)/737869762948382064640000000 – (29738775089977568461*rpm4)/360287970189639680000000 + w_kp
Any idea how to fix the subs command to get it to truly substitute for all symbolic vars? syms, symbolic variables, subs MATLAB Answers — New Questions
Is it possible to use the simulink model as a function in matlab?
I’d like to call a model I’ve created on simulink as a matlab function. Is this possible?I’d like to call a model I’ve created on simulink as a matlab function. Is this possible? I’d like to call a model I’ve created on simulink as a matlab function. Is this possible? function, simulink MATLAB Answers — New Questions
How to implement a multiple nested “nested loop” faster in MATLAB
I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this?I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this? I want to implement the following formula in MATLAB. This formula represents point spread function(PSF) from concentrating point to grid point :
I have to implement this formula multiple time in MATLAB. So, running speed is very important to me. and are vectors with 40000 elements (albeit, we can represent and in 2D format) . Also, is a vector with 1400 elements and has 51 elements. For each , we have to sum over all and and also, over all (because we want to calculate PSF from to all grid points ). Also we want to implment this PSF for all . in the worst implementation, we have 4 for-loop with lots of elements. Definitely, it decrease speed by a huge amount. So, how can I avoid this? speed, for loop, nested-for loop MATLAB Answers — New Questions
Why does my Nlgreyest freezes when used?
I am trying to identify a nonlinear model with the nlgreyest command. Where the Filename is mij nonlinear model as a function handle. The function handle works perfectly when using the sim or even the step command to check if my function works.
However when the nlgreyest is used with display on, the display freezes, status remains busy, and looks like the figure below.
When I massively mash ctrl+c, I get the following error and nlgreyest seems to load.
I have tried to reduce the number of data points but that doesnt seem to work. I have tried to use different solvers, 15s and 23s because of stiffness. I tried to reduce the number of outputs and measured outputs. I also tried a linear estimation using greyest and a linear model and this does work.
I don’t really what goes wrong here.
Its a 3 Output, 1 Input, 5 State model.
Order = [3,1,5];
Init = struct(‘Name’, {‘Angle’ ‘Angular Velocity’ ‘Current A’ ‘Current B’ ‘Current C’},…
‘Unit’, {‘rad’ ‘rad/s’ ‘A’ ‘A’ ‘A’},…
‘Value’, {0 0 0 0 0},…
‘Minimum’, {-inf -inf -inf -inf -inf},…
‘Maximum’, {inf inf inf inf inf},…
‘Fixed’, {true true true true true});
% AZ 3 Phase
Parameters = struct(‘Name’, {‘Inertia’ ‘Viscous Friction’ ‘Inductance’ ‘Reistance’ ‘Motor Torque Constant’ ‘Motor Omega Constant’ ‘Pole Pairs’},…
‘Unit’, {‘kg/m^2’ ‘kg/m/s’ ‘Henry’ ‘Ohm’ ‘Nm/A’ ‘V/rad/s’ ‘-‘},…
‘Value’, {Jm Bm La Ra Kt Kv PolePairs},…
‘Minimum’, {1e-6 1e-5 1e-5 1e-2 1e-2 1e-2 -inf},…
‘Maximum’, {1e-3 1e-2 1e-2 1e1 1e1 1e1 inf},…
‘Fixed’, {false false false false false false true});
optnl = nlgreyestOptions;
optnl.Display = ‘on’;
optnl.SearchMethod = ‘lm’;
nlgr = idnlgrey(FileName, Order, Parameters, Init,0);
datar = iddata(y, u, dt);
nlgr = nlgreyest(datar, nlgr, optnl);I am trying to identify a nonlinear model with the nlgreyest command. Where the Filename is mij nonlinear model as a function handle. The function handle works perfectly when using the sim or even the step command to check if my function works.
However when the nlgreyest is used with display on, the display freezes, status remains busy, and looks like the figure below.
When I massively mash ctrl+c, I get the following error and nlgreyest seems to load.
I have tried to reduce the number of data points but that doesnt seem to work. I have tried to use different solvers, 15s and 23s because of stiffness. I tried to reduce the number of outputs and measured outputs. I also tried a linear estimation using greyest and a linear model and this does work.
I don’t really what goes wrong here.
Its a 3 Output, 1 Input, 5 State model.
Order = [3,1,5];
Init = struct(‘Name’, {‘Angle’ ‘Angular Velocity’ ‘Current A’ ‘Current B’ ‘Current C’},…
‘Unit’, {‘rad’ ‘rad/s’ ‘A’ ‘A’ ‘A’},…
‘Value’, {0 0 0 0 0},…
‘Minimum’, {-inf -inf -inf -inf -inf},…
‘Maximum’, {inf inf inf inf inf},…
‘Fixed’, {true true true true true});
% AZ 3 Phase
Parameters = struct(‘Name’, {‘Inertia’ ‘Viscous Friction’ ‘Inductance’ ‘Reistance’ ‘Motor Torque Constant’ ‘Motor Omega Constant’ ‘Pole Pairs’},…
‘Unit’, {‘kg/m^2’ ‘kg/m/s’ ‘Henry’ ‘Ohm’ ‘Nm/A’ ‘V/rad/s’ ‘-‘},…
‘Value’, {Jm Bm La Ra Kt Kv PolePairs},…
‘Minimum’, {1e-6 1e-5 1e-5 1e-2 1e-2 1e-2 -inf},…
‘Maximum’, {1e-3 1e-2 1e-2 1e1 1e1 1e1 inf},…
‘Fixed’, {false false false false false false true});
optnl = nlgreyestOptions;
optnl.Display = ‘on’;
optnl.SearchMethod = ‘lm’;
nlgr = idnlgrey(FileName, Order, Parameters, Init,0);
datar = iddata(y, u, dt);
nlgr = nlgreyest(datar, nlgr, optnl); I am trying to identify a nonlinear model with the nlgreyest command. Where the Filename is mij nonlinear model as a function handle. The function handle works perfectly when using the sim or even the step command to check if my function works.
However when the nlgreyest is used with display on, the display freezes, status remains busy, and looks like the figure below.
When I massively mash ctrl+c, I get the following error and nlgreyest seems to load.
I have tried to reduce the number of data points but that doesnt seem to work. I have tried to use different solvers, 15s and 23s because of stiffness. I tried to reduce the number of outputs and measured outputs. I also tried a linear estimation using greyest and a linear model and this does work.
I don’t really what goes wrong here.
Its a 3 Output, 1 Input, 5 State model.
Order = [3,1,5];
Init = struct(‘Name’, {‘Angle’ ‘Angular Velocity’ ‘Current A’ ‘Current B’ ‘Current C’},…
‘Unit’, {‘rad’ ‘rad/s’ ‘A’ ‘A’ ‘A’},…
‘Value’, {0 0 0 0 0},…
‘Minimum’, {-inf -inf -inf -inf -inf},…
‘Maximum’, {inf inf inf inf inf},…
‘Fixed’, {true true true true true});
% AZ 3 Phase
Parameters = struct(‘Name’, {‘Inertia’ ‘Viscous Friction’ ‘Inductance’ ‘Reistance’ ‘Motor Torque Constant’ ‘Motor Omega Constant’ ‘Pole Pairs’},…
‘Unit’, {‘kg/m^2’ ‘kg/m/s’ ‘Henry’ ‘Ohm’ ‘Nm/A’ ‘V/rad/s’ ‘-‘},…
‘Value’, {Jm Bm La Ra Kt Kv PolePairs},…
‘Minimum’, {1e-6 1e-5 1e-5 1e-2 1e-2 1e-2 -inf},…
‘Maximum’, {1e-3 1e-2 1e-2 1e1 1e1 1e1 inf},…
‘Fixed’, {false false false false false false true});
optnl = nlgreyestOptions;
optnl.Display = ‘on’;
optnl.SearchMethod = ‘lm’;
nlgr = idnlgrey(FileName, Order, Parameters, Init,0);
datar = iddata(y, u, dt);
nlgr = nlgreyest(datar, nlgr, optnl); nlgreyest, idnlgrey, iddata, identification, nonlinear, system identification MATLAB Answers — New Questions
Is it normal for a trained RL agent to take the same actions for 10 simulations ?
Hello, I trained a TD3 agent using the RL Toolbox and the agent is giving a better reward than the untrained agent. But the trained agent is giving the same actions and the same reward for 10 simulations (I used the "Simulate" option of the Toolbox). Is this behaviour normal for an RL agent ?
Thank you in advance.Hello, I trained a TD3 agent using the RL Toolbox and the agent is giving a better reward than the untrained agent. But the trained agent is giving the same actions and the same reward for 10 simulations (I used the "Simulate" option of the Toolbox). Is this behaviour normal for an RL agent ?
Thank you in advance. Hello, I trained a TD3 agent using the RL Toolbox and the agent is giving a better reward than the untrained agent. But the trained agent is giving the same actions and the same reward for 10 simulations (I used the "Simulate" option of the Toolbox). Is this behaviour normal for an RL agent ?
Thank you in advance. rl, machine learning, simulation, matlab, ai MATLAB Answers — New Questions
How can I apply variable transparency to a plot using scatter3?
I’m producing a 3D model, and interior points happen to be more interesting to me. I have a 4-column matrix representing (x,y,z,intensity), and I’m most interested in the high-intensity points; currently they’re coloured by intensity. Can I make it so that the transparency of low-intensity points is increased (but I need them to still be visible)?
ThanksI’m producing a 3D model, and interior points happen to be more interesting to me. I have a 4-column matrix representing (x,y,z,intensity), and I’m most interested in the high-intensity points; currently they’re coloured by intensity. Can I make it so that the transparency of low-intensity points is increased (but I need them to still be visible)?
Thanks I’m producing a 3D model, and interior points happen to be more interesting to me. I have a 4-column matrix representing (x,y,z,intensity), and I’m most interested in the high-intensity points; currently they’re coloured by intensity. Can I make it so that the transparency of low-intensity points is increased (but I need them to still be visible)?
Thanks 3d, scatter, transparency, alpha, markers MATLAB Answers — New Questions
why does it change the number when using VPA?
why does it change the number? let alone that its not 100 digits.
clear all
s=vpa(1.316074012952492460819218901796999055160068590205822176731922658595866795197302133050743150246601931520047742334253421353091380742095,100)why does it change the number? let alone that its not 100 digits.
clear all
s=vpa(1.316074012952492460819218901796999055160068590205822176731922658595866795197302133050743150246601931520047742334253421353091380742095,100) why does it change the number? let alone that its not 100 digits.
clear all
s=vpa(1.316074012952492460819218901796999055160068590205822176731922658595866795197302133050743150246601931520047742334253421353091380742095,100) vpa, precision MATLAB Answers — New Questions
How to better graphically represent this data?
Greetings,
So I have three varaiables R1,R2 and R3. Each variable has an actual real value and a calculated value. For each variable I am calculating the error and storing them in variables called R1error, R2error and R3error. To represent this data in a table form is easy, I just make a table for each error with all possible combination values within the range. The problem comes when I want to graphically represent this data. If I follow the same logic, I will have three 3d graphs that will represent the error. But is there a better way to represent this data? For example if someone wanted to look up what is the error at R1 = 100, R2 = 200 and R3 = 300, they will have to look at the three separate graphs and come to conclusions which is not very intuitive since all the errors are related to each other. If someone has a better idea, I would be grateful for the help.Greetings,
So I have three varaiables R1,R2 and R3. Each variable has an actual real value and a calculated value. For each variable I am calculating the error and storing them in variables called R1error, R2error and R3error. To represent this data in a table form is easy, I just make a table for each error with all possible combination values within the range. The problem comes when I want to graphically represent this data. If I follow the same logic, I will have three 3d graphs that will represent the error. But is there a better way to represent this data? For example if someone wanted to look up what is the error at R1 = 100, R2 = 200 and R3 = 300, they will have to look at the three separate graphs and come to conclusions which is not very intuitive since all the errors are related to each other. If someone has a better idea, I would be grateful for the help. Greetings,
So I have three varaiables R1,R2 and R3. Each variable has an actual real value and a calculated value. For each variable I am calculating the error and storing them in variables called R1error, R2error and R3error. To represent this data in a table form is easy, I just make a table for each error with all possible combination values within the range. The problem comes when I want to graphically represent this data. If I follow the same logic, I will have three 3d graphs that will represent the error. But is there a better way to represent this data? For example if someone wanted to look up what is the error at R1 = 100, R2 = 200 and R3 = 300, they will have to look at the three separate graphs and come to conclusions which is not very intuitive since all the errors are related to each other. If someone has a better idea, I would be grateful for the help. graph MATLAB Answers — New Questions
MATLAB program to split a given matrix A into two matrices B & C such that B+C=A.
Hi,
Can you help me splitting a matrix A into B & C such that B+C=A? I need a code to generate all possible combinations of B & C.
For example, if A=[1 2 2 4;2 4 3 0;8 4 0 5;-3 4 5 0] then, B=[1 0 2 0;0 0 3 0;8 4 0 0;-3 0 0 0] and C=[0 2 0 4;2 4 0 0;0 0 0 5;0 4 5 0] are a pair of suitable combinations. I need all possible combinations in which (almost) half of the non zero elements are in B and remaining are in C.
Thank you.Hi,
Can you help me splitting a matrix A into B & C such that B+C=A? I need a code to generate all possible combinations of B & C.
For example, if A=[1 2 2 4;2 4 3 0;8 4 0 5;-3 4 5 0] then, B=[1 0 2 0;0 0 3 0;8 4 0 0;-3 0 0 0] and C=[0 2 0 4;2 4 0 0;0 0 0 5;0 4 5 0] are a pair of suitable combinations. I need all possible combinations in which (almost) half of the non zero elements are in B and remaining are in C.
Thank you. Hi,
Can you help me splitting a matrix A into B & C such that B+C=A? I need a code to generate all possible combinations of B & C.
For example, if A=[1 2 2 4;2 4 3 0;8 4 0 5;-3 4 5 0] then, B=[1 0 2 0;0 0 3 0;8 4 0 0;-3 0 0 0] and C=[0 2 0 4;2 4 0 0;0 0 0 5;0 4 5 0] are a pair of suitable combinations. I need all possible combinations in which (almost) half of the non zero elements are in B and remaining are in C.
Thank you. split matrix MATLAB Answers — New Questions
Solving system of nonlinear differential equations using ode45
I have a question for system of ordinary differential equations, because Matlab gives some strange solution as output. There is the code:
Jo1=1;
Jo2=2;
Jo3=3;
Mo1=1;
Mo2=1;
Mo3=1;
f=@(t,x)[x(4).*sin(x(3))./sin(x(2))+x(5).*cos(x(3))./sin(x(2));
cos(x(3)).*x(4)-sin(x(3)).*x(5);
-x(4).*sin(x(3)).*cos(x(2))./sin(x(2))-x(6).*cos(x(3)).*cos(x(2))./sin(x(2));
(Mo1-(Jo3-Jo2).*x(6).*x(5))./Jo1;
(Mo2-(Jo1-Jo3).*x(4).*x(6))./Jo2;
(Mo3-(Jo2-Jo1).*x(5).*x(4))./Jo3];
[t, x]= ode45(f, [0,1],[0,0,0,0,0,0]);
I get solution for x4, x5 and x6, but for x1, x2 and x3 the solution is NaN.
So if someone have any advice it would help.I have a question for system of ordinary differential equations, because Matlab gives some strange solution as output. There is the code:
Jo1=1;
Jo2=2;
Jo3=3;
Mo1=1;
Mo2=1;
Mo3=1;
f=@(t,x)[x(4).*sin(x(3))./sin(x(2))+x(5).*cos(x(3))./sin(x(2));
cos(x(3)).*x(4)-sin(x(3)).*x(5);
-x(4).*sin(x(3)).*cos(x(2))./sin(x(2))-x(6).*cos(x(3)).*cos(x(2))./sin(x(2));
(Mo1-(Jo3-Jo2).*x(6).*x(5))./Jo1;
(Mo2-(Jo1-Jo3).*x(4).*x(6))./Jo2;
(Mo3-(Jo2-Jo1).*x(5).*x(4))./Jo3];
[t, x]= ode45(f, [0,1],[0,0,0,0,0,0]);
I get solution for x4, x5 and x6, but for x1, x2 and x3 the solution is NaN.
So if someone have any advice it would help. I have a question for system of ordinary differential equations, because Matlab gives some strange solution as output. There is the code:
Jo1=1;
Jo2=2;
Jo3=3;
Mo1=1;
Mo2=1;
Mo3=1;
f=@(t,x)[x(4).*sin(x(3))./sin(x(2))+x(5).*cos(x(3))./sin(x(2));
cos(x(3)).*x(4)-sin(x(3)).*x(5);
-x(4).*sin(x(3)).*cos(x(2))./sin(x(2))-x(6).*cos(x(3)).*cos(x(2))./sin(x(2));
(Mo1-(Jo3-Jo2).*x(6).*x(5))./Jo1;
(Mo2-(Jo1-Jo3).*x(4).*x(6))./Jo2;
(Mo3-(Jo2-Jo1).*x(5).*x(4))./Jo3];
[t, x]= ode45(f, [0,1],[0,0,0,0,0,0]);
I get solution for x4, x5 and x6, but for x1, x2 and x3 the solution is NaN.
So if someone have any advice it would help. ode45, nonlinear, differential equations MATLAB Answers — New Questions
TRiggered Subsystem is taking very high time
Hi,
I have a simulation with several matlab function block in my simulation and I am using SampleTime to trigger it at different frequencies.
Now as part of the test I want to vary the frequency of these blocks and see the behavior of simulation. I am not able to change the SampleTime variable as all the blocks of this simulation are Encrypted in the end.
I am thinking of redesigning it as Edge Triggered subsytem, so that I can controll the clock externally. But the moment I add triggered block on top of the Matlab Function. It becomes very slow.
Can some help why the same simulation with same execution rate is very slow with triggered block?
I have checked with SImulink Profiler that the majority of timeis being consumed by the Triggered subsytem.Hi,
I have a simulation with several matlab function block in my simulation and I am using SampleTime to trigger it at different frequencies.
Now as part of the test I want to vary the frequency of these blocks and see the behavior of simulation. I am not able to change the SampleTime variable as all the blocks of this simulation are Encrypted in the end.
I am thinking of redesigning it as Edge Triggered subsytem, so that I can controll the clock externally. But the moment I add triggered block on top of the Matlab Function. It becomes very slow.
Can some help why the same simulation with same execution rate is very slow with triggered block?
I have checked with SImulink Profiler that the majority of timeis being consumed by the Triggered subsytem. Hi,
I have a simulation with several matlab function block in my simulation and I am using SampleTime to trigger it at different frequencies.
Now as part of the test I want to vary the frequency of these blocks and see the behavior of simulation. I am not able to change the SampleTime variable as all the blocks of this simulation are Encrypted in the end.
I am thinking of redesigning it as Edge Triggered subsytem, so that I can controll the clock externally. But the moment I add triggered block on top of the Matlab Function. It becomes very slow.
Can some help why the same simulation with same execution rate is very slow with triggered block?
I have checked with SImulink Profiler that the majority of timeis being consumed by the Triggered subsytem. simulink, performance MATLAB Answers — New Questions
How do i switch between sources in a Simulink (Simscape) model acroding to a Workspace variable?
I have a simscape simulink model, as shown in the picture:
I would like a specific run of the simulation to switch between the 4 possible signal sources acording to a Workspace variable WS. In other words, if WS=1 when the simulation runs, i would want the step signal to be the source. If WS=2 i would like the slope to be the sourse etc.
I saw some similar question and answers, but still havn’t figured it out. Any help?
Thanks!I have a simscape simulink model, as shown in the picture:
I would like a specific run of the simulation to switch between the 4 possible signal sources acording to a Workspace variable WS. In other words, if WS=1 when the simulation runs, i would want the step signal to be the source. If WS=2 i would like the slope to be the sourse etc.
I saw some similar question and answers, but still havn’t figured it out. Any help?
Thanks! I have a simscape simulink model, as shown in the picture:
I would like a specific run of the simulation to switch between the 4 possible signal sources acording to a Workspace variable WS. In other words, if WS=1 when the simulation runs, i would want the step signal to be the source. If WS=2 i would like the slope to be the sourse etc.
I saw some similar question and answers, but still havn’t figured it out. Any help?
Thanks! simulink, simscape MATLAB Answers — New Questions
How to generate traceability report between requirement and simulink test?
I need to generate the traceability between requirement and simulink test.
In the simulink test, we are mentioning the requirements in requirement tab or section. So i want to generate a traceability report which will list test case to requirement and vice versa.
I need traceability report to be generated which will list test reference and the corresponding requirement covered in that test.I need to generate the traceability between requirement and simulink test.
In the simulink test, we are mentioning the requirements in requirement tab or section. So i want to generate a traceability report which will list test case to requirement and vice versa.
I need traceability report to be generated which will list test reference and the corresponding requirement covered in that test. I need to generate the traceability between requirement and simulink test.
In the simulink test, we are mentioning the requirements in requirement tab or section. So i want to generate a traceability report which will list test case to requirement and vice versa.
I need traceability report to be generated which will list test reference and the corresponding requirement covered in that test. traceability report, simulink test traceability, test case to requirement traceability. MATLAB Answers — New Questions