Tag Archives: matlab
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
Generate matrix combinations with parameters
I have the following matrix (8×6):
M = [T_1 T_2 T_3 0 0 0
T_1 0 T_2 T_3 0 0
T_1 0 0 T_2 T_3 0
T_1 T_2 0 0 T_3 0
0 T_1 T_2 0 0 T_3
0 0 T_1 T_2 0 T_3
0 0 0 T_1 T_2 T_3
0 T_1 0 0 T_2 T_3]
where T has the following possibilities: {1,0,0}, {0,1,0}, {0,0,1} or {1,1,1} and T_i is the i-component of T.
How can I create all possible combinations for M?I have the following matrix (8×6):
M = [T_1 T_2 T_3 0 0 0
T_1 0 T_2 T_3 0 0
T_1 0 0 T_2 T_3 0
T_1 T_2 0 0 T_3 0
0 T_1 T_2 0 0 T_3
0 0 T_1 T_2 0 T_3
0 0 0 T_1 T_2 T_3
0 T_1 0 0 T_2 T_3]
where T has the following possibilities: {1,0,0}, {0,1,0}, {0,0,1} or {1,1,1} and T_i is the i-component of T.
How can I create all possible combinations for M? I have the following matrix (8×6):
M = [T_1 T_2 T_3 0 0 0
T_1 0 T_2 T_3 0 0
T_1 0 0 T_2 T_3 0
T_1 T_2 0 0 T_3 0
0 T_1 T_2 0 0 T_3
0 0 T_1 T_2 0 T_3
0 0 0 T_1 T_2 T_3
0 T_1 0 0 T_2 T_3]
where T has the following possibilities: {1,0,0}, {0,1,0}, {0,0,1} or {1,1,1} and T_i is the i-component of T.
How can I create all possible combinations for M? combinations, matrices MATLAB Answers — New Questions
How to display table values
I am trying to get the command window to show the actual value of my table instead of saying [1×41 double].
Below is my working out:
A=(10:0.1:14);
M; %Array of Maximum values
I; %Array of Index of Maximum values
maxtheta = theta(I);
%%Add Table with A vs M vs I
T = table(A,M,maxtheta,’VariableNames’,{‘a value’,’max db value’,’corresponding angle’})
When i click run, this is what it is displaying:
T =
1×3 table
a value max db value corresponding angle
____________ _____________ ___________________
[1×41 double] [1×41 double] [1×41 double]
How can I get it to show the actual values?I am trying to get the command window to show the actual value of my table instead of saying [1×41 double].
Below is my working out:
A=(10:0.1:14);
M; %Array of Maximum values
I; %Array of Index of Maximum values
maxtheta = theta(I);
%%Add Table with A vs M vs I
T = table(A,M,maxtheta,’VariableNames’,{‘a value’,’max db value’,’corresponding angle’})
When i click run, this is what it is displaying:
T =
1×3 table
a value max db value corresponding angle
____________ _____________ ___________________
[1×41 double] [1×41 double] [1×41 double]
How can I get it to show the actual values? I am trying to get the command window to show the actual value of my table instead of saying [1×41 double].
Below is my working out:
A=(10:0.1:14);
M; %Array of Maximum values
I; %Array of Index of Maximum values
maxtheta = theta(I);
%%Add Table with A vs M vs I
T = table(A,M,maxtheta,’VariableNames’,{‘a value’,’max db value’,’corresponding angle’})
When i click run, this is what it is displaying:
T =
1×3 table
a value max db value corresponding angle
____________ _____________ ___________________
[1×41 double] [1×41 double] [1×41 double]
How can I get it to show the actual values? table, array, values MATLAB Answers — New Questions
directory does not update
When I choose a new program to run the directory does not update, so I have to manually go to "browse for folder" and find where this program is located manually. is there a solution to this or is it a bug?When I choose a new program to run the directory does not update, so I have to manually go to "browse for folder" and find where this program is located manually. is there a solution to this or is it a bug? When I choose a new program to run the directory does not update, so I have to manually go to "browse for folder" and find where this program is located manually. is there a solution to this or is it a bug? directory, browse, matlab, bug MATLAB Answers — New Questions
Calculating Gravity Torque for ABB IRB1410
Can the gravity torque of the ABB IRB1410 with a parallel structure be calculated using the gravityTorque() function of the Robotics System Toolbox?Can the gravity torque of the ABB IRB1410 with a parallel structure be calculated using the gravityTorque() function of the Robotics System Toolbox? Can the gravity torque of the ABB IRB1410 with a parallel structure be calculated using the gravityTorque() function of the Robotics System Toolbox? abb, irb1410, gravity torque MATLAB Answers — New Questions
How to link Autodesk Inventor 2025 files to Simscape Multibody, if you mention that they only have until the Autodesk 2021 version?
Post Content Post Content autodesk inventor 2025, simscape multibody, plugin MATLAB Answers — New Questions
Connecting Fuse in Simscape Transformer Circuit
Apologies if this is a dumb question, but I opened up the power_transformer Simscape example and attempted to add a Simscape Fuse block (Switches and Breakers/Fuse). However when I try to connect a terminal of the fuse to a terminal of the included transformer it won’t allow it (circle with cross inside). It also won’t connect to the included Simscape Fundamental Block/Parallel RLC load. Maybe I need to stick some sort of converter in-line to allow the connection?
Thanks.Apologies if this is a dumb question, but I opened up the power_transformer Simscape example and attempted to add a Simscape Fuse block (Switches and Breakers/Fuse). However when I try to connect a terminal of the fuse to a terminal of the included transformer it won’t allow it (circle with cross inside). It also won’t connect to the included Simscape Fundamental Block/Parallel RLC load. Maybe I need to stick some sort of converter in-line to allow the connection?
Thanks. Apologies if this is a dumb question, but I opened up the power_transformer Simscape example and attempted to add a Simscape Fuse block (Switches and Breakers/Fuse). However when I try to connect a terminal of the fuse to a terminal of the included transformer it won’t allow it (circle with cross inside). It also won’t connect to the included Simscape Fundamental Block/Parallel RLC load. Maybe I need to stick some sort of converter in-line to allow the connection?
Thanks. simulink, simscape, fuse MATLAB Answers — New Questions
Save document with custom properties with actxserver Word
The following script shall change custom properties of a word document using the activexserver syntax for Microsoft Word.
%% Initiallize Word Connection
hdlWord = actxserver(‘Word.Application’);
hdlWord.Visible = true;
%% File and Location
fullLocation = ‘C:UsersNameDocumentsMATLABPropTest.docx’;
hdlDoc = hdlWord.Documents.Open(fullLocation);
%% Property Change
hdlProp = get(hdlDoc.CustomDocumentProperties, ‘Item’, ‘Property1’);
get(hdlProp,’Value’);
set(hdlProp,’Value’,’nice’); % saved as "jealous" before running the script
%% Save Doc
hdlWord.ActiveDocument.SaveAs2(fullLocation)
hdlDoc.Close();
hdlWord.Quit();
The property change itself is working. Sadly, the script is not saving the document. There is no error or warning given out.
If I comment the close functions and click save manually it works fine.
If I save the document as a another file the properties are changed and saved. Therefore, a work around by deleting and renaming and so on would work.
Could someone help me out on how to save the opened document and close it by script?The following script shall change custom properties of a word document using the activexserver syntax for Microsoft Word.
%% Initiallize Word Connection
hdlWord = actxserver(‘Word.Application’);
hdlWord.Visible = true;
%% File and Location
fullLocation = ‘C:UsersNameDocumentsMATLABPropTest.docx’;
hdlDoc = hdlWord.Documents.Open(fullLocation);
%% Property Change
hdlProp = get(hdlDoc.CustomDocumentProperties, ‘Item’, ‘Property1’);
get(hdlProp,’Value’);
set(hdlProp,’Value’,’nice’); % saved as "jealous" before running the script
%% Save Doc
hdlWord.ActiveDocument.SaveAs2(fullLocation)
hdlDoc.Close();
hdlWord.Quit();
The property change itself is working. Sadly, the script is not saving the document. There is no error or warning given out.
If I comment the close functions and click save manually it works fine.
If I save the document as a another file the properties are changed and saved. Therefore, a work around by deleting and renaming and so on would work.
Could someone help me out on how to save the opened document and close it by script? The following script shall change custom properties of a word document using the activexserver syntax for Microsoft Word.
%% Initiallize Word Connection
hdlWord = actxserver(‘Word.Application’);
hdlWord.Visible = true;
%% File and Location
fullLocation = ‘C:UsersNameDocumentsMATLABPropTest.docx’;
hdlDoc = hdlWord.Documents.Open(fullLocation);
%% Property Change
hdlProp = get(hdlDoc.CustomDocumentProperties, ‘Item’, ‘Property1’);
get(hdlProp,’Value’);
set(hdlProp,’Value’,’nice’); % saved as "jealous" before running the script
%% Save Doc
hdlWord.ActiveDocument.SaveAs2(fullLocation)
hdlDoc.Close();
hdlWord.Quit();
The property change itself is working. Sadly, the script is not saving the document. There is no error or warning given out.
If I comment the close functions and click save manually it works fine.
If I save the document as a another file the properties are changed and saved. Therefore, a work around by deleting and renaming and so on would work.
Could someone help me out on how to save the opened document and close it by script? matlab, activexserver, word, save MATLAB Answers — New Questions
Using output of a function into the integral2 Function – Unrecognized function or variable
Hello,
I’m currently facing an issue with using an output of a function into an integral.
I have attached my code for reference:
P_RAD.m
Unfortunately, for this case, I have to use a function in my code because I need it to plot certain parameters. I understand what the error is saying and why it is saying it. I’m trying to see if there is a workaround for this.
This is the integration I am trying to do: See screenshot attached: P_RAD_Integration.png
The error that I’m facing is shown below.
% Unrecognized function or variable ‘U_Rad’.
Error in Patterns (line 200)
P_rad = U_Rad.*sin(theta);Hello,
I’m currently facing an issue with using an output of a function into an integral.
I have attached my code for reference:
P_RAD.m
Unfortunately, for this case, I have to use a function in my code because I need it to plot certain parameters. I understand what the error is saying and why it is saying it. I’m trying to see if there is a workaround for this.
This is the integration I am trying to do: See screenshot attached: P_RAD_Integration.png
The error that I’m facing is shown below.
% Unrecognized function or variable ‘U_Rad’.
Error in Patterns (line 200)
P_rad = U_Rad.*sin(theta); Hello,
I’m currently facing an issue with using an output of a function into an integral.
I have attached my code for reference:
P_RAD.m
Unfortunately, for this case, I have to use a function in my code because I need it to plot certain parameters. I understand what the error is saying and why it is saying it. I’m trying to see if there is a workaround for this.
This is the integration I am trying to do: See screenshot attached: P_RAD_Integration.png
The error that I’m facing is shown below.
% Unrecognized function or variable ‘U_Rad’.
Error in Patterns (line 200)
P_rad = U_Rad.*sin(theta); integral, integration, numerical integration MATLAB Answers — New Questions
Obtain intensity values within the ROIs drawn on image in this script. Then, write and display intensity values within the ROIs on the image.
clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas?clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas? clear all
close all
% UUT image input
I = imread(‘UUT33.bmp’);
R = imresize(I, [800 1000]); % Resize image to full res
% Define ROI size
ROIWidth = 100;
ROIHeight = 100;
% Number of ROIs in X and Y directions
numROIsX = 3;
numROIsY = 3;
% Calculate the step size for placing ROIs
stepX = floor(size(R, 2) / (numROIsX + 1));
stepY = floor(size(R, 1) / (numROIsY + 1));
% Initialize ROI positions
ROIPositionsX = zeros(numROIsX, 1);
ROIPositionsY = zeros(numROIsY, 1);
% Calculate ROI positions based on the step size
for i = 1:numROIsX
ROIPositionsX(i) = i * stepX – floor(ROIWidth / 2);
end
for j = 1:numROIsY
ROIPositionsY(j) = j * stepY – floor(ROIHeight / 2);
end
% Create ROIs and visualize
figure;
imshow(R); % Display the original image
hold on; % Hold the current plot
% Loop through each ROI position and draw rectangles on image
for i = 1:numROIsX
for j = 1:numROIsY
x = ROIPositionsX(i);
y = ROIPositionsY(j);
rectangle(‘Position’, [x, y, ROIWidth, ROIHeight], ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);
end
end
hold off; % Release hold on current plot
title(‘ROIs on image in exact positions’);
This scirpt inputs an image and draws rectangle ROIs in specific positions on the image. I need to obtain the intensity values within all of the ROIs, and then write in /display the intensity values wihin all of the drawn ROIs on the image. Any ideas? intensity values in rois in image MATLAB Answers — New Questions