Category: Matlab
Category Archives: Matlab
How to spot infinite loops
I am working on feature extraction for eeg data. However, everytime I run the code it just keep percolating through the 4th file for the same first 10/56 features. I have checked all the for loops to make sure they have the appropriate end to them. It looks like its working for the first file and it will try to go to file two and then it just redoes that file over and over only for the first 10 features.I am working on feature extraction for eeg data. However, everytime I run the code it just keep percolating through the 4th file for the same first 10/56 features. I have checked all the for loops to make sure they have the appropriate end to them. It looks like its working for the first file and it will try to go to file two and then it just redoes that file over and over only for the first 10 features. I am working on feature extraction for eeg data. However, everytime I run the code it just keep percolating through the 4th file for the same first 10/56 features. I have checked all the for loops to make sure they have the appropriate end to them. It looks like its working for the first file and it will try to go to file two and then it just redoes that file over and over only for the first 10 features. #infinite #loops MATLAB Answers — New Questions
cameraIntrinsics expects ‘abcd’ to be type double, single.
I need to specify camera Intrinsics.
For this i wrote:
KameraInnereien=cameraIntrinsics(‘focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
When executing i get the Error:
Error using cameraIntrinsics
Expected abcd to be one of these types:
double, single
Error in vision.internal.cameraIntrinsicsImpl>parseInputsSimulation (line 223)
validateattributes(focalLength, {‘double’, ‘single’}, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl>parseInputs (line 213)
r = parseInputsSimulation(defaultParams,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl (line 82)
r = parseInputs(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^
Error in cameraIntrinsics (line 17)
this = this@vision.internal.cameraIntrinsicsImpl(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in CV (line 134)
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]); %’focalLength’,[0 0] ,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Looking into the function that throws the Error shows the variable ‘abcd’, (which is kinda weird it looks like a Placeholder):
function r = parseInputsSimulation(defaultParams,varargin)
parser = inputParser;
focalLength = varargin{1};
validateattributes(focalLength, {‘double’, ‘single’}, …
{‘vector’,’real’, ‘nonsparse’, ‘finite’, ‘positive’}, …
‘cameraIntrinsics’, ‘abcd’);
filename = ‘cameraIntrinsics’;
parser.addRequired(‘focalLength’, @(f)vision.internal.inputValidation.validateFocalLength(f,filename));
parser.addRequired(‘principalPoint’, @(p)vision.internal.inputValidation.validatePrincipalPoint(p,filename));
parser.addRequired(‘imageSize’, @(sz)vision.internal.inputValidation.validateImageSize(sz,filename));
parser.addParameter(‘RadialDistortion’, defaultParams.RadialDistortion, …
@vision.internal.calibration.CameraParametersImpl.checkRadialDistortion);
parser.addParameter(‘TangentialDistortion’, defaultParams.TangentialDistortion,…
@vision.internal.calibration.CameraParametersImpl.checkTangentialDistortion);
parser.addParameter(‘Skew’, defaultParams.Skew, @cameraIntrinsics.checkSkew);
% Parse and check optional parameters
parser.parse(varargin{:});
r = parser.Results;
end
What shall i do to avoid it, i tried declaring abcd when calling cameraIntrinsics, but obviously that did not work.
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
Doing it with string Names " " instead of char ‘ ‘ does obviously not change the outcome.
Is abcd a Placeholder that is not implemented right or is the error on my part?I need to specify camera Intrinsics.
For this i wrote:
KameraInnereien=cameraIntrinsics(‘focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
When executing i get the Error:
Error using cameraIntrinsics
Expected abcd to be one of these types:
double, single
Error in vision.internal.cameraIntrinsicsImpl>parseInputsSimulation (line 223)
validateattributes(focalLength, {‘double’, ‘single’}, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl>parseInputs (line 213)
r = parseInputsSimulation(defaultParams,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl (line 82)
r = parseInputs(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^
Error in cameraIntrinsics (line 17)
this = this@vision.internal.cameraIntrinsicsImpl(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in CV (line 134)
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]); %’focalLength’,[0 0] ,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Looking into the function that throws the Error shows the variable ‘abcd’, (which is kinda weird it looks like a Placeholder):
function r = parseInputsSimulation(defaultParams,varargin)
parser = inputParser;
focalLength = varargin{1};
validateattributes(focalLength, {‘double’, ‘single’}, …
{‘vector’,’real’, ‘nonsparse’, ‘finite’, ‘positive’}, …
‘cameraIntrinsics’, ‘abcd’);
filename = ‘cameraIntrinsics’;
parser.addRequired(‘focalLength’, @(f)vision.internal.inputValidation.validateFocalLength(f,filename));
parser.addRequired(‘principalPoint’, @(p)vision.internal.inputValidation.validatePrincipalPoint(p,filename));
parser.addRequired(‘imageSize’, @(sz)vision.internal.inputValidation.validateImageSize(sz,filename));
parser.addParameter(‘RadialDistortion’, defaultParams.RadialDistortion, …
@vision.internal.calibration.CameraParametersImpl.checkRadialDistortion);
parser.addParameter(‘TangentialDistortion’, defaultParams.TangentialDistortion,…
@vision.internal.calibration.CameraParametersImpl.checkTangentialDistortion);
parser.addParameter(‘Skew’, defaultParams.Skew, @cameraIntrinsics.checkSkew);
% Parse and check optional parameters
parser.parse(varargin{:});
r = parser.Results;
end
What shall i do to avoid it, i tried declaring abcd when calling cameraIntrinsics, but obviously that did not work.
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
Doing it with string Names " " instead of char ‘ ‘ does obviously not change the outcome.
Is abcd a Placeholder that is not implemented right or is the error on my part? I need to specify camera Intrinsics.
For this i wrote:
KameraInnereien=cameraIntrinsics(‘focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
When executing i get the Error:
Error using cameraIntrinsics
Expected abcd to be one of these types:
double, single
Error in vision.internal.cameraIntrinsicsImpl>parseInputsSimulation (line 223)
validateattributes(focalLength, {‘double’, ‘single’}, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl>parseInputs (line 213)
r = parseInputsSimulation(defaultParams,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in vision.internal.cameraIntrinsicsImpl (line 82)
r = parseInputs(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^
Error in cameraIntrinsics (line 17)
this = this@vision.internal.cameraIntrinsicsImpl(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in CV (line 134)
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]); %’focalLength’,[0 0] ,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Looking into the function that throws the Error shows the variable ‘abcd’, (which is kinda weird it looks like a Placeholder):
function r = parseInputsSimulation(defaultParams,varargin)
parser = inputParser;
focalLength = varargin{1};
validateattributes(focalLength, {‘double’, ‘single’}, …
{‘vector’,’real’, ‘nonsparse’, ‘finite’, ‘positive’}, …
‘cameraIntrinsics’, ‘abcd’);
filename = ‘cameraIntrinsics’;
parser.addRequired(‘focalLength’, @(f)vision.internal.inputValidation.validateFocalLength(f,filename));
parser.addRequired(‘principalPoint’, @(p)vision.internal.inputValidation.validatePrincipalPoint(p,filename));
parser.addRequired(‘imageSize’, @(sz)vision.internal.inputValidation.validateImageSize(sz,filename));
parser.addParameter(‘RadialDistortion’, defaultParams.RadialDistortion, …
@vision.internal.calibration.CameraParametersImpl.checkRadialDistortion);
parser.addParameter(‘TangentialDistortion’, defaultParams.TangentialDistortion,…
@vision.internal.calibration.CameraParametersImpl.checkTangentialDistortion);
parser.addParameter(‘Skew’, defaultParams.Skew, @cameraIntrinsics.checkSkew);
% Parse and check optional parameters
parser.parse(varargin{:});
r = parser.Results;
end
What shall i do to avoid it, i tried declaring abcd when calling cameraIntrinsics, but obviously that did not work.
KameraInnereien=cameraIntrinsics(‘abcd’,1 ,’focalLength’,[0 0] ,’ImageSize’,[1440 2560],’PrincipalPoint’,[720 1280]);
Doing it with string Names " " instead of char ‘ ‘ does obviously not change the outcome.
Is abcd a Placeholder that is not implemented right or is the error on my part? cameraintrinsics, abcd, image processing MATLAB Answers — New Questions
How to sort filenames that are stored by dir command
list = dir(‘*.bmp’);
%preallocate cell array
img = cell(length(list),1);
f = cell(length(list), 250-100);
for i = 1:length(list)
img{i} = imread(list(i).name);
end
%Loop through each image
for i = 1:length(list)
a=img{i}
b=rgb2gray(a);
imwrite(b,sprintf(‘%d.png’,i))
end
That is the simplified code
Problem is that
"dir" command read files in false order, for example:
file1, file11, file111, file2, file22, file222, file3, file33, file333
in fact it should be
file 1, file 2, file 3, file 11, file 22, file 33, file 111, file 222, file 333
How can sort this order in correct versionlist = dir(‘*.bmp’);
%preallocate cell array
img = cell(length(list),1);
f = cell(length(list), 250-100);
for i = 1:length(list)
img{i} = imread(list(i).name);
end
%Loop through each image
for i = 1:length(list)
a=img{i}
b=rgb2gray(a);
imwrite(b,sprintf(‘%d.png’,i))
end
That is the simplified code
Problem is that
"dir" command read files in false order, for example:
file1, file11, file111, file2, file22, file222, file3, file33, file333
in fact it should be
file 1, file 2, file 3, file 11, file 22, file 33, file 111, file 222, file 333
How can sort this order in correct version list = dir(‘*.bmp’);
%preallocate cell array
img = cell(length(list),1);
f = cell(length(list), 250-100);
for i = 1:length(list)
img{i} = imread(list(i).name);
end
%Loop through each image
for i = 1:length(list)
a=img{i}
b=rgb2gray(a);
imwrite(b,sprintf(‘%d.png’,i))
end
That is the simplified code
Problem is that
"dir" command read files in false order, for example:
file1, file11, file111, file2, file22, file222, file3, file33, file333
in fact it should be
file 1, file 2, file 3, file 11, file 22, file 33, file 111, file 222, file 333
How can sort this order in correct version reading images from folder in correct order, filename sorting, natsortfiles MATLAB Answers — New Questions
Error using ilwt Expected LEVEL to be a scalar with value <= 1.
[ca,cd] = lwt(x1,’LiftingScheme’,lsc,’Level’,2,’Int2Int’,true);
…working on ca
x11 = ilwt(double(CA), cd, ‘LiftingScheme’,lsc,’Int2Int’,true,’Level’,2);
Error using ilwt
Expected LEVEL to be a scalar with value <= 1.
Error in ilwt>ilwtParser (line 339)
validateattributes(level, {‘numeric’},…
Error in ilwt (line 82)
[LS,ext,level,~,isI2I] = ilwtParser(lvl,varargin{:});[ca,cd] = lwt(x1,’LiftingScheme’,lsc,’Level’,2,’Int2Int’,true);
…working on ca
x11 = ilwt(double(CA), cd, ‘LiftingScheme’,lsc,’Int2Int’,true,’Level’,2);
Error using ilwt
Expected LEVEL to be a scalar with value <= 1.
Error in ilwt>ilwtParser (line 339)
validateattributes(level, {‘numeric’},…
Error in ilwt (line 82)
[LS,ext,level,~,isI2I] = ilwtParser(lvl,varargin{:}); [ca,cd] = lwt(x1,’LiftingScheme’,lsc,’Level’,2,’Int2Int’,true);
…working on ca
x11 = ilwt(double(CA), cd, ‘LiftingScheme’,lsc,’Int2Int’,true,’Level’,2);
Error using ilwt
Expected LEVEL to be a scalar with value <= 1.
Error in ilwt>ilwtParser (line 339)
validateattributes(level, {‘numeric’},…
Error in ilwt (line 82)
[LS,ext,level,~,isI2I] = ilwtParser(lvl,varargin{:}); expected level to be a scalar with value = 1. MATLAB Answers — New Questions
Crash when installing toolbox on WSL Ubuntu.
Hi, I am currently trying to install Optimization Toolbox on my Ubuntu installation (Windows Subsystem for Linux). Unfortunately, whenever I get to the stage where MATLAB tries to restart and complete installation, I get the following crash:
——————————————————————————–
Segmentation violation detected at 2025-01-20 11:47:37 -0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
GNU C Library : 2.35 stable
Graphics Driver : Uninitialized hardware
Graphics card 1 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Graphics card 2 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : glnxa64
MATLAB Entitlement ID : 4172689
MATLAB Root : /usr/local/MATLAB/R2024b
MATLAB Version : 24.2.0.2806996 (R2024b) Update 3
OpenGL : hardware
Operating System : Ubuntu 22.04.3 LTS
Process ID : 419451
Processor ID : x86 Family 6 Model 154 Stepping 3, GenuineIntel
Session Key : 53e159c3-dfdf-45f4-8a51-aef078491d42
Window System : Microsoft Corporation (12010000), display :0
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ‘MCR 0 interpret’ id 139820436284992
Register State (from fault):
RAX = 0000000000000001 RBX = 00007f2a7b6feb38
RCX = 00000000000000bb RDX = 00007f29c6374b10
RSP = 00007f2a7b6fdc58 RBP = 00007f2cec6d7cc8
RSI = 0000000000000000 RDI = 00007f2a69028940
R8 = 0000000000000000 R9 = 0000000000000000
R10 = 0000000000000008 R11 = 6474ee0e92b55eb5
R12 = 0000000000000000 R13 = 00007f2cec6d7ae8
R14 = 0000000000000004 R15 = 00007f2a7b6feb58
RIP = 00007f29c6374b10 EFL = 0000000000010202
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f29c6374b10 <unknown-module>+00000000
[ 1] 0x00007f2cec54c691 /lib/x86_64-linux-gnu/libc.so.6+00595601
[ 2] 0x00007f2cec54f94a /lib/x86_64-linux-gnu/libc.so.6+00608586
[ 3] 0x00007f2cec5e1850 /lib/x86_64-linux-gnu/libc.so.6+01206352
** This crash report has been saved to disk as /home/polaris/matlab_crash_dump.419451-1 **
MATLAB is exiting because of fatal error
Killed
Does anyone know what is causing this and how to fix it?
Thanks!Hi, I am currently trying to install Optimization Toolbox on my Ubuntu installation (Windows Subsystem for Linux). Unfortunately, whenever I get to the stage where MATLAB tries to restart and complete installation, I get the following crash:
——————————————————————————–
Segmentation violation detected at 2025-01-20 11:47:37 -0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
GNU C Library : 2.35 stable
Graphics Driver : Uninitialized hardware
Graphics card 1 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Graphics card 2 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : glnxa64
MATLAB Entitlement ID : 4172689
MATLAB Root : /usr/local/MATLAB/R2024b
MATLAB Version : 24.2.0.2806996 (R2024b) Update 3
OpenGL : hardware
Operating System : Ubuntu 22.04.3 LTS
Process ID : 419451
Processor ID : x86 Family 6 Model 154 Stepping 3, GenuineIntel
Session Key : 53e159c3-dfdf-45f4-8a51-aef078491d42
Window System : Microsoft Corporation (12010000), display :0
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ‘MCR 0 interpret’ id 139820436284992
Register State (from fault):
RAX = 0000000000000001 RBX = 00007f2a7b6feb38
RCX = 00000000000000bb RDX = 00007f29c6374b10
RSP = 00007f2a7b6fdc58 RBP = 00007f2cec6d7cc8
RSI = 0000000000000000 RDI = 00007f2a69028940
R8 = 0000000000000000 R9 = 0000000000000000
R10 = 0000000000000008 R11 = 6474ee0e92b55eb5
R12 = 0000000000000000 R13 = 00007f2cec6d7ae8
R14 = 0000000000000004 R15 = 00007f2a7b6feb58
RIP = 00007f29c6374b10 EFL = 0000000000010202
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f29c6374b10 <unknown-module>+00000000
[ 1] 0x00007f2cec54c691 /lib/x86_64-linux-gnu/libc.so.6+00595601
[ 2] 0x00007f2cec54f94a /lib/x86_64-linux-gnu/libc.so.6+00608586
[ 3] 0x00007f2cec5e1850 /lib/x86_64-linux-gnu/libc.so.6+01206352
** This crash report has been saved to disk as /home/polaris/matlab_crash_dump.419451-1 **
MATLAB is exiting because of fatal error
Killed
Does anyone know what is causing this and how to fix it?
Thanks! Hi, I am currently trying to install Optimization Toolbox on my Ubuntu installation (Windows Subsystem for Linux). Unfortunately, whenever I get to the stage where MATLAB tries to restart and complete installation, I get the following crash:
——————————————————————————–
Segmentation violation detected at 2025-01-20 11:47:37 -0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
GNU C Library : 2.35 stable
Graphics Driver : Uninitialized hardware
Graphics card 1 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Graphics card 2 : 0x1414 ( 0x1414 ) 0x8e Version 2.0.3.0 (0-0-0)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : glnxa64
MATLAB Entitlement ID : 4172689
MATLAB Root : /usr/local/MATLAB/R2024b
MATLAB Version : 24.2.0.2806996 (R2024b) Update 3
OpenGL : hardware
Operating System : Ubuntu 22.04.3 LTS
Process ID : 419451
Processor ID : x86 Family 6 Model 154 Stepping 3, GenuineIntel
Session Key : 53e159c3-dfdf-45f4-8a51-aef078491d42
Window System : Microsoft Corporation (12010000), display :0
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: ‘MCR 0 interpret’ id 139820436284992
Register State (from fault):
RAX = 0000000000000001 RBX = 00007f2a7b6feb38
RCX = 00000000000000bb RDX = 00007f29c6374b10
RSP = 00007f2a7b6fdc58 RBP = 00007f2cec6d7cc8
RSI = 0000000000000000 RDI = 00007f2a69028940
R8 = 0000000000000000 R9 = 0000000000000000
R10 = 0000000000000008 R11 = 6474ee0e92b55eb5
R12 = 0000000000000000 R13 = 00007f2cec6d7ae8
R14 = 0000000000000004 R15 = 00007f2a7b6feb58
RIP = 00007f29c6374b10 EFL = 0000000000010202
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f29c6374b10 <unknown-module>+00000000
[ 1] 0x00007f2cec54c691 /lib/x86_64-linux-gnu/libc.so.6+00595601
[ 2] 0x00007f2cec54f94a /lib/x86_64-linux-gnu/libc.so.6+00608586
[ 3] 0x00007f2cec5e1850 /lib/x86_64-linux-gnu/libc.so.6+01206352
** This crash report has been saved to disk as /home/polaris/matlab_crash_dump.419451-1 **
MATLAB is exiting because of fatal error
Killed
Does anyone know what is causing this and how to fix it?
Thanks! linux, toolbox, installation, optimization MATLAB Answers — New Questions
truncated rowname in uitable
hi, I see the truncated rowname in uitable
How can i display full name in uitable rowname?
RowName=compose(formatSpec,t1,sist);
app.UITable.RowName=RowName’;hi, I see the truncated rowname in uitable
How can i display full name in uitable rowname?
RowName=compose(formatSpec,t1,sist);
app.UITable.RowName=RowName’; hi, I see the truncated rowname in uitable
How can i display full name in uitable rowname?
RowName=compose(formatSpec,t1,sist);
app.UITable.RowName=RowName’; truncated rowname in uitable MATLAB Answers — New Questions
Data extraction from table
Hello everyone,
Let’s say I have the following table in an excel sheet I read in matlab:
I just want to extract all rows with the same data,text,val to another table, so here in this case I should have table1 with the first 3 rows, table2 with row4 and 5 and table3 with the last row.
The issue may be trivial but I can’t seem to see how to do it, it has been a long time since I used matlab, I tried with find or groupcounts and other functions but it I’m stuck.
Any help is appreciated!Hello everyone,
Let’s say I have the following table in an excel sheet I read in matlab:
I just want to extract all rows with the same data,text,val to another table, so here in this case I should have table1 with the first 3 rows, table2 with row4 and 5 and table3 with the last row.
The issue may be trivial but I can’t seem to see how to do it, it has been a long time since I used matlab, I tried with find or groupcounts and other functions but it I’m stuck.
Any help is appreciated! Hello everyone,
Let’s say I have the following table in an excel sheet I read in matlab:
I just want to extract all rows with the same data,text,val to another table, so here in this case I should have table1 with the first 3 rows, table2 with row4 and 5 and table3 with the last row.
The issue may be trivial but I can’t seem to see how to do it, it has been a long time since I used matlab, I tried with find or groupcounts and other functions but it I’m stuck.
Any help is appreciated! data extraction, table, excel MATLAB Answers — New Questions
How can I save an output of a customized step function in Reinforcement learning?
I have created a code for training a DQN agent with a customized enviroment using step and reset function following the example in the docuemntation. However I would like to be able to store the info about the state in the step function to investigate them after the training and after simulating the agent in the enviroment. I only know how to get the info about action and observation but I would kike also the state that now is a field of the structure LoggedSignals. I attach the main code and the step function and the reset function.
clear
clc
close all
load(‘ws_lorenz’,’tot_T’)
%% Create Environment Interface
% rlNumericSpec([n,1]) specifies that the state variables are n and can
% take any value in R.
obsInfo = rlNumericSpec([1 1]);
obsInfo.Name = ‘reactivity’;
obsInfo.Description = ‘r’;
u_1 = [0.1 2];
my_cell = reshape(num2cell(u_1),1,length(u_1));
actInfo = rlFiniteSetSpec(my_cell);
actInfo.Name = ‘System Action’;
% now we are ready to define the environment.
%doc rlSimulinkEnv Create reinforcement learning environment using dynamic model implemented in Simulink
%doc rlFunctionEnv Specify custom reinforcement learning environment dynamics using functions
env = rlFunctionEnv(obsInfo,actInfo,’my_stepfun’,’my_resetfun’);
% Fix the random generator seed for reproducibility.
rng(0)
%% Create DQN agent
%A DQN agent approximates the long-term reward given observations and
%actions using a critic value function representation.
%To create the critic, first create a deep neural network with the state as
% an input and as many outputs as the different values the control action
% can take (this is the size of the cell). The idea here is to obtain a
% different parametric approximator of the Q-factor for each value of u.
net = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(length(actInfo.Elements))
];
net = dlnetwork(net);
summary(net)
% Plot network
plot(net)
% Specify options for the critic. The LearnRate is key, the higher it is, the
% faster the training but potentially the less accurate the results.
criticOptions = rlOptimizerOptions( …
LearnRate=1e-3, …
GradientThreshold=1);
%specify the action and observation info for the critic, which you obtain
%from the environment interface.
obsInfo = getObservationInfo(env);
actInfo = getActionInfo(env);
% A vector Q-value Function is a neural network allowing to obtain a
% different parametric approximator of the Q-factor for each value of u.
critic = rlVectorQValueFunction(net,obsInfo,actInfo);
%To create the DQN agent, first specify the DQN agent options using rlDQNAgentOptions.
agentOpts = rlDQNAgentOptions(…
‘UseDoubleDQN’,true, …
‘TargetUpdateMethod’,"periodic", …
‘TargetUpdateFrequency’,10, …
‘ExperienceBufferLength’,100000, …
‘DiscountFactor’,0.95, …
‘MiniBatchSize’,128, …
CriticOptimizerOptions=criticOptions);
agentOpts.EpsilonGreedyExploration.Epsilon = 0.8;
agentOpts.EpsilonGreedyExploration.EpsilonDecay = 1e-3;
agentOpts.EpsilonGreedyExploration.EpsilonMin = 0.1;
%Then, create the DQN agent using the specified critic representation
%and agent options.
agent = rlDQNAgent(critic,agentOpts);
%% Train Agent
%To train the agent, first specify the training options.
%Run one training session containing at most 1000 episodes,
%with each episode lasting at most 500 time steps.
%Display the training progress in the Episode Manager dialog box
%and disable the command line display (set the Verbose option to false).
%Stop training when the agent receives an moving average cumulative reward
%greater than 15000.
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 10000, … % if the number of steps per episode is increased, this could be decreased.
‘MaxStepsPerEpisode’, tot_T, … % this number of steps per episode might be insufficient in general
‘Verbose’, false, …
‘Plots’,’training-progress’,…
‘StopTrainingCriteria’,’AverageReward’,…
‘StopTrainingValue’,1, …
UseParallel=false);
%% Train the agent using the train function.
trainingStats = train(agent,env,trainOpts);
%% Simulate DQN Agent
%To validate the performance of the trained agent, simulate it within the
% environment.
experience = sim(env,agent);
totalReward = sum(experience.Reward)
figure(1)
x = squeeze(experience.Action.SystemAction.Data(:,1,:));%%1x1x258
plot(x’)
plot(squeeze(experience.Action.SystemAction.Data));
title(‘Actions Over Time’);
react = squeeze(experience.Observation.reactivity.Data(:,1,:)); %%1x1x259
figure(2)
plot(react’)
title(‘Reactivity Over Time’);
figure(3)
plot(trainingStats.EpisodeIndex, trainingStats.AverageReward);
xlabel(‘Episode’);
ylabel(‘Average Reward’);
function [NextObs,Reward,IsDone,LoggedSignals]…
= my_stepfun(Action,LoggedSignals)
% Custom step function.
%[NextObservation,Reward,IsDone,UpdatedInfo] = myStepFunction(Action,Info)
% This function applies the given action to the environment and evaluates
% the system dynamics for one simulation step.
% Define the environment constants.
% Sample time
Ts = 1;
sig = 1.3;
DF= LoggedSignals.DF ;
L = LoggedSignals.L;
H = LoggedSignals.H;
xi = LoggedSignals.xi;
m = LoggedSignals.m;
n = LoggedSignals.n;
tot_T = LoggedSignals.tot_T;
LoggedSignals.Time = LoggedSignals.Time+Ts;
kk = (1/Ts)*LoggedSignals.Time;
u = Action;
% Unpack the state vector from the logged signals.
x_k = LoggedSignals.State;
% Perform Euler integration.
[t, x] = ode113(@(t,x)my_lorenz_DQN(t,x,L,u, DF, H),[0 Ts],x_k’);
LoggedSignals.State = x(end,:)’;
% compute average state
St = [mean(x(end,1:n),2), mean(x(end,n+1:2*n),2), mean(x(end,2*n+1:3*n),2)];
% compute reactivity (using sig)
r = max(eig((DF(St) + DF(St)’)/2 +sig*xi*H));
% The next observation is the reactivity
NextObs = r;
% Check early termination condition.
[err, ~, ~] = Err_sync(x, t, n, m, 0);
if LoggedSignals.Time >= 0.9*tot_T
LoggedSignals.cum_err = LoggedSignals.cum_err+err;
end
IsDone1 = LoggedSignals.cum_err>(20*eps);
IsDone2 = err>1e-1;
w1 = 1e5;
w2 = 1e2;
if IsDone1==1
Reward = -(tot_T-LoggedSignals.Time)*1e3;
elseif IsDone2==1
Reward = -(tot_T-LoggedSignals.Time)*1e4;
else
Reward = 1 -w1*err – w2*u;
end
IsDone = max(IsDone1,IsDone2) ;
end
function [InitialObservation, LoggedSignal] = my_resetfun()
load(‘reset_ws.mat’,’x0′)
load(‘ws_lorenz’,’DF’,’L’,’H’,’xi’,’n’,’m’,’tot_T’)
x = x0(:,randi(size(x0,2)));
LoggedSignal.State = x;
InitialObservation = 1; %% da cambiare
LoggedSignal.Time = 0;
LoggedSignal.DF = DF;
LoggedSignal.L = L;
LoggedSignal.H = H;
LoggedSignal.xi = xi;
LoggedSignal.m = m;
LoggedSignal.n = n;
LoggedSignal.cum_err = 0;
LoggedSignal.tot_T = tot_T;
endI have created a code for training a DQN agent with a customized enviroment using step and reset function following the example in the docuemntation. However I would like to be able to store the info about the state in the step function to investigate them after the training and after simulating the agent in the enviroment. I only know how to get the info about action and observation but I would kike also the state that now is a field of the structure LoggedSignals. I attach the main code and the step function and the reset function.
clear
clc
close all
load(‘ws_lorenz’,’tot_T’)
%% Create Environment Interface
% rlNumericSpec([n,1]) specifies that the state variables are n and can
% take any value in R.
obsInfo = rlNumericSpec([1 1]);
obsInfo.Name = ‘reactivity’;
obsInfo.Description = ‘r’;
u_1 = [0.1 2];
my_cell = reshape(num2cell(u_1),1,length(u_1));
actInfo = rlFiniteSetSpec(my_cell);
actInfo.Name = ‘System Action’;
% now we are ready to define the environment.
%doc rlSimulinkEnv Create reinforcement learning environment using dynamic model implemented in Simulink
%doc rlFunctionEnv Specify custom reinforcement learning environment dynamics using functions
env = rlFunctionEnv(obsInfo,actInfo,’my_stepfun’,’my_resetfun’);
% Fix the random generator seed for reproducibility.
rng(0)
%% Create DQN agent
%A DQN agent approximates the long-term reward given observations and
%actions using a critic value function representation.
%To create the critic, first create a deep neural network with the state as
% an input and as many outputs as the different values the control action
% can take (this is the size of the cell). The idea here is to obtain a
% different parametric approximator of the Q-factor for each value of u.
net = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(length(actInfo.Elements))
];
net = dlnetwork(net);
summary(net)
% Plot network
plot(net)
% Specify options for the critic. The LearnRate is key, the higher it is, the
% faster the training but potentially the less accurate the results.
criticOptions = rlOptimizerOptions( …
LearnRate=1e-3, …
GradientThreshold=1);
%specify the action and observation info for the critic, which you obtain
%from the environment interface.
obsInfo = getObservationInfo(env);
actInfo = getActionInfo(env);
% A vector Q-value Function is a neural network allowing to obtain a
% different parametric approximator of the Q-factor for each value of u.
critic = rlVectorQValueFunction(net,obsInfo,actInfo);
%To create the DQN agent, first specify the DQN agent options using rlDQNAgentOptions.
agentOpts = rlDQNAgentOptions(…
‘UseDoubleDQN’,true, …
‘TargetUpdateMethod’,"periodic", …
‘TargetUpdateFrequency’,10, …
‘ExperienceBufferLength’,100000, …
‘DiscountFactor’,0.95, …
‘MiniBatchSize’,128, …
CriticOptimizerOptions=criticOptions);
agentOpts.EpsilonGreedyExploration.Epsilon = 0.8;
agentOpts.EpsilonGreedyExploration.EpsilonDecay = 1e-3;
agentOpts.EpsilonGreedyExploration.EpsilonMin = 0.1;
%Then, create the DQN agent using the specified critic representation
%and agent options.
agent = rlDQNAgent(critic,agentOpts);
%% Train Agent
%To train the agent, first specify the training options.
%Run one training session containing at most 1000 episodes,
%with each episode lasting at most 500 time steps.
%Display the training progress in the Episode Manager dialog box
%and disable the command line display (set the Verbose option to false).
%Stop training when the agent receives an moving average cumulative reward
%greater than 15000.
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 10000, … % if the number of steps per episode is increased, this could be decreased.
‘MaxStepsPerEpisode’, tot_T, … % this number of steps per episode might be insufficient in general
‘Verbose’, false, …
‘Plots’,’training-progress’,…
‘StopTrainingCriteria’,’AverageReward’,…
‘StopTrainingValue’,1, …
UseParallel=false);
%% Train the agent using the train function.
trainingStats = train(agent,env,trainOpts);
%% Simulate DQN Agent
%To validate the performance of the trained agent, simulate it within the
% environment.
experience = sim(env,agent);
totalReward = sum(experience.Reward)
figure(1)
x = squeeze(experience.Action.SystemAction.Data(:,1,:));%%1x1x258
plot(x’)
plot(squeeze(experience.Action.SystemAction.Data));
title(‘Actions Over Time’);
react = squeeze(experience.Observation.reactivity.Data(:,1,:)); %%1x1x259
figure(2)
plot(react’)
title(‘Reactivity Over Time’);
figure(3)
plot(trainingStats.EpisodeIndex, trainingStats.AverageReward);
xlabel(‘Episode’);
ylabel(‘Average Reward’);
function [NextObs,Reward,IsDone,LoggedSignals]…
= my_stepfun(Action,LoggedSignals)
% Custom step function.
%[NextObservation,Reward,IsDone,UpdatedInfo] = myStepFunction(Action,Info)
% This function applies the given action to the environment and evaluates
% the system dynamics for one simulation step.
% Define the environment constants.
% Sample time
Ts = 1;
sig = 1.3;
DF= LoggedSignals.DF ;
L = LoggedSignals.L;
H = LoggedSignals.H;
xi = LoggedSignals.xi;
m = LoggedSignals.m;
n = LoggedSignals.n;
tot_T = LoggedSignals.tot_T;
LoggedSignals.Time = LoggedSignals.Time+Ts;
kk = (1/Ts)*LoggedSignals.Time;
u = Action;
% Unpack the state vector from the logged signals.
x_k = LoggedSignals.State;
% Perform Euler integration.
[t, x] = ode113(@(t,x)my_lorenz_DQN(t,x,L,u, DF, H),[0 Ts],x_k’);
LoggedSignals.State = x(end,:)’;
% compute average state
St = [mean(x(end,1:n),2), mean(x(end,n+1:2*n),2), mean(x(end,2*n+1:3*n),2)];
% compute reactivity (using sig)
r = max(eig((DF(St) + DF(St)’)/2 +sig*xi*H));
% The next observation is the reactivity
NextObs = r;
% Check early termination condition.
[err, ~, ~] = Err_sync(x, t, n, m, 0);
if LoggedSignals.Time >= 0.9*tot_T
LoggedSignals.cum_err = LoggedSignals.cum_err+err;
end
IsDone1 = LoggedSignals.cum_err>(20*eps);
IsDone2 = err>1e-1;
w1 = 1e5;
w2 = 1e2;
if IsDone1==1
Reward = -(tot_T-LoggedSignals.Time)*1e3;
elseif IsDone2==1
Reward = -(tot_T-LoggedSignals.Time)*1e4;
else
Reward = 1 -w1*err – w2*u;
end
IsDone = max(IsDone1,IsDone2) ;
end
function [InitialObservation, LoggedSignal] = my_resetfun()
load(‘reset_ws.mat’,’x0′)
load(‘ws_lorenz’,’DF’,’L’,’H’,’xi’,’n’,’m’,’tot_T’)
x = x0(:,randi(size(x0,2)));
LoggedSignal.State = x;
InitialObservation = 1; %% da cambiare
LoggedSignal.Time = 0;
LoggedSignal.DF = DF;
LoggedSignal.L = L;
LoggedSignal.H = H;
LoggedSignal.xi = xi;
LoggedSignal.m = m;
LoggedSignal.n = n;
LoggedSignal.cum_err = 0;
LoggedSignal.tot_T = tot_T;
end I have created a code for training a DQN agent with a customized enviroment using step and reset function following the example in the docuemntation. However I would like to be able to store the info about the state in the step function to investigate them after the training and after simulating the agent in the enviroment. I only know how to get the info about action and observation but I would kike also the state that now is a field of the structure LoggedSignals. I attach the main code and the step function and the reset function.
clear
clc
close all
load(‘ws_lorenz’,’tot_T’)
%% Create Environment Interface
% rlNumericSpec([n,1]) specifies that the state variables are n and can
% take any value in R.
obsInfo = rlNumericSpec([1 1]);
obsInfo.Name = ‘reactivity’;
obsInfo.Description = ‘r’;
u_1 = [0.1 2];
my_cell = reshape(num2cell(u_1),1,length(u_1));
actInfo = rlFiniteSetSpec(my_cell);
actInfo.Name = ‘System Action’;
% now we are ready to define the environment.
%doc rlSimulinkEnv Create reinforcement learning environment using dynamic model implemented in Simulink
%doc rlFunctionEnv Specify custom reinforcement learning environment dynamics using functions
env = rlFunctionEnv(obsInfo,actInfo,’my_stepfun’,’my_resetfun’);
% Fix the random generator seed for reproducibility.
rng(0)
%% Create DQN agent
%A DQN agent approximates the long-term reward given observations and
%actions using a critic value function representation.
%To create the critic, first create a deep neural network with the state as
% an input and as many outputs as the different values the control action
% can take (this is the size of the cell). The idea here is to obtain a
% different parametric approximator of the Q-factor for each value of u.
net = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(256)
reluLayer
fullyConnectedLayer(length(actInfo.Elements))
];
net = dlnetwork(net);
summary(net)
% Plot network
plot(net)
% Specify options for the critic. The LearnRate is key, the higher it is, the
% faster the training but potentially the less accurate the results.
criticOptions = rlOptimizerOptions( …
LearnRate=1e-3, …
GradientThreshold=1);
%specify the action and observation info for the critic, which you obtain
%from the environment interface.
obsInfo = getObservationInfo(env);
actInfo = getActionInfo(env);
% A vector Q-value Function is a neural network allowing to obtain a
% different parametric approximator of the Q-factor for each value of u.
critic = rlVectorQValueFunction(net,obsInfo,actInfo);
%To create the DQN agent, first specify the DQN agent options using rlDQNAgentOptions.
agentOpts = rlDQNAgentOptions(…
‘UseDoubleDQN’,true, …
‘TargetUpdateMethod’,"periodic", …
‘TargetUpdateFrequency’,10, …
‘ExperienceBufferLength’,100000, …
‘DiscountFactor’,0.95, …
‘MiniBatchSize’,128, …
CriticOptimizerOptions=criticOptions);
agentOpts.EpsilonGreedyExploration.Epsilon = 0.8;
agentOpts.EpsilonGreedyExploration.EpsilonDecay = 1e-3;
agentOpts.EpsilonGreedyExploration.EpsilonMin = 0.1;
%Then, create the DQN agent using the specified critic representation
%and agent options.
agent = rlDQNAgent(critic,agentOpts);
%% Train Agent
%To train the agent, first specify the training options.
%Run one training session containing at most 1000 episodes,
%with each episode lasting at most 500 time steps.
%Display the training progress in the Episode Manager dialog box
%and disable the command line display (set the Verbose option to false).
%Stop training when the agent receives an moving average cumulative reward
%greater than 15000.
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 10000, … % if the number of steps per episode is increased, this could be decreased.
‘MaxStepsPerEpisode’, tot_T, … % this number of steps per episode might be insufficient in general
‘Verbose’, false, …
‘Plots’,’training-progress’,…
‘StopTrainingCriteria’,’AverageReward’,…
‘StopTrainingValue’,1, …
UseParallel=false);
%% Train the agent using the train function.
trainingStats = train(agent,env,trainOpts);
%% Simulate DQN Agent
%To validate the performance of the trained agent, simulate it within the
% environment.
experience = sim(env,agent);
totalReward = sum(experience.Reward)
figure(1)
x = squeeze(experience.Action.SystemAction.Data(:,1,:));%%1x1x258
plot(x’)
plot(squeeze(experience.Action.SystemAction.Data));
title(‘Actions Over Time’);
react = squeeze(experience.Observation.reactivity.Data(:,1,:)); %%1x1x259
figure(2)
plot(react’)
title(‘Reactivity Over Time’);
figure(3)
plot(trainingStats.EpisodeIndex, trainingStats.AverageReward);
xlabel(‘Episode’);
ylabel(‘Average Reward’);
function [NextObs,Reward,IsDone,LoggedSignals]…
= my_stepfun(Action,LoggedSignals)
% Custom step function.
%[NextObservation,Reward,IsDone,UpdatedInfo] = myStepFunction(Action,Info)
% This function applies the given action to the environment and evaluates
% the system dynamics for one simulation step.
% Define the environment constants.
% Sample time
Ts = 1;
sig = 1.3;
DF= LoggedSignals.DF ;
L = LoggedSignals.L;
H = LoggedSignals.H;
xi = LoggedSignals.xi;
m = LoggedSignals.m;
n = LoggedSignals.n;
tot_T = LoggedSignals.tot_T;
LoggedSignals.Time = LoggedSignals.Time+Ts;
kk = (1/Ts)*LoggedSignals.Time;
u = Action;
% Unpack the state vector from the logged signals.
x_k = LoggedSignals.State;
% Perform Euler integration.
[t, x] = ode113(@(t,x)my_lorenz_DQN(t,x,L,u, DF, H),[0 Ts],x_k’);
LoggedSignals.State = x(end,:)’;
% compute average state
St = [mean(x(end,1:n),2), mean(x(end,n+1:2*n),2), mean(x(end,2*n+1:3*n),2)];
% compute reactivity (using sig)
r = max(eig((DF(St) + DF(St)’)/2 +sig*xi*H));
% The next observation is the reactivity
NextObs = r;
% Check early termination condition.
[err, ~, ~] = Err_sync(x, t, n, m, 0);
if LoggedSignals.Time >= 0.9*tot_T
LoggedSignals.cum_err = LoggedSignals.cum_err+err;
end
IsDone1 = LoggedSignals.cum_err>(20*eps);
IsDone2 = err>1e-1;
w1 = 1e5;
w2 = 1e2;
if IsDone1==1
Reward = -(tot_T-LoggedSignals.Time)*1e3;
elseif IsDone2==1
Reward = -(tot_T-LoggedSignals.Time)*1e4;
else
Reward = 1 -w1*err – w2*u;
end
IsDone = max(IsDone1,IsDone2) ;
end
function [InitialObservation, LoggedSignal] = my_resetfun()
load(‘reset_ws.mat’,’x0′)
load(‘ws_lorenz’,’DF’,’L’,’H’,’xi’,’n’,’m’,’tot_T’)
x = x0(:,randi(size(x0,2)));
LoggedSignal.State = x;
InitialObservation = 1; %% da cambiare
LoggedSignal.Time = 0;
LoggedSignal.DF = DF;
LoggedSignal.L = L;
LoggedSignal.H = H;
LoggedSignal.xi = xi;
LoggedSignal.m = m;
LoggedSignal.n = n;
LoggedSignal.cum_err = 0;
LoggedSignal.tot_T = tot_T;
end deep learning, save MATLAB Answers — New Questions
Ignore uicomponents when pressing the tab key in App Designer
I have an GUI in AppDesigner and I’m using the tab key to jump from one component to other but I need to find a way to ignore some uicomponents without setting the ‘Enable’ Property of the component to ignore to ‘off’.
As an example, in the attached gif you can see what is happening right now and what I expect to do. I have two Edit Fields and a uitable and what I want to do is to go from the Edit Field1 to Edit Field2 pressing the Tab Key ignoring the uitable.
I know I can get a similar behavior chaning the order of the components in the Component Browser but this has a problem which is that If I jump from Edit Field1 to Edit Field2 and press the Tab Key again it will take me to the uitable. In this case, the expected behavior will be that once I lay on the Edit Field2 and press Tab Ket again, it will take me to the Edit Field1.
Finally, I can’t set the ‘Enable’ property of the ignored component to ‘off’ because I use that component. (In the example suppose that the uitable has a Celledit callback that I will use in other moment)
PD: The example is purely ilustrative, please don’t put your attention in the design or other aspects.
Thanks in advance,I have an GUI in AppDesigner and I’m using the tab key to jump from one component to other but I need to find a way to ignore some uicomponents without setting the ‘Enable’ Property of the component to ignore to ‘off’.
As an example, in the attached gif you can see what is happening right now and what I expect to do. I have two Edit Fields and a uitable and what I want to do is to go from the Edit Field1 to Edit Field2 pressing the Tab Key ignoring the uitable.
I know I can get a similar behavior chaning the order of the components in the Component Browser but this has a problem which is that If I jump from Edit Field1 to Edit Field2 and press the Tab Key again it will take me to the uitable. In this case, the expected behavior will be that once I lay on the Edit Field2 and press Tab Ket again, it will take me to the Edit Field1.
Finally, I can’t set the ‘Enable’ property of the ignored component to ‘off’ because I use that component. (In the example suppose that the uitable has a Celledit callback that I will use in other moment)
PD: The example is purely ilustrative, please don’t put your attention in the design or other aspects.
Thanks in advance, I have an GUI in AppDesigner and I’m using the tab key to jump from one component to other but I need to find a way to ignore some uicomponents without setting the ‘Enable’ Property of the component to ignore to ‘off’.
As an example, in the attached gif you can see what is happening right now and what I expect to do. I have two Edit Fields and a uitable and what I want to do is to go from the Edit Field1 to Edit Field2 pressing the Tab Key ignoring the uitable.
I know I can get a similar behavior chaning the order of the components in the Component Browser but this has a problem which is that If I jump from Edit Field1 to Edit Field2 and press the Tab Key again it will take me to the uitable. In this case, the expected behavior will be that once I lay on the Edit Field2 and press Tab Ket again, it will take me to the Edit Field1.
Finally, I can’t set the ‘Enable’ property of the ignored component to ‘off’ because I use that component. (In the example suppose that the uitable has a Celledit callback that I will use in other moment)
PD: The example is purely ilustrative, please don’t put your attention in the design or other aspects.
Thanks in advance, appdesigner, matlab, ui component, tab key MATLAB Answers — New Questions
error in web application: A fatal error has been detected by the Java Runtime Environment
I have an online application in a server so that I can use the webapps envyroment. This year one of the applications doesn’t wor because of a Java runtime error that seems to come from the server itself. The issue is the application worked just fine before so now I’m trying to undertand possible causes and solutions to this issue.
Matlab version is 2018a;
The fist part of the erro message is shown below.
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffdcd35696d, pid=7900, tid=0x0000000000001c98
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
#
C
0x00007ffdcd35696d
#
# Core dump written. Default location: C:UsersMATLABWebAppsGuestAppDataLocalMathWorkswebappsservicesmdwassessions868f2753-24fa-47f2-a64f-981cf6d48615hs_err_pid7900.mdmp
#
# An error report file with more information is saved as:
# C:ProgramDataMathWorkswebappsR2018alogshs_error_pid7900.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.I have an online application in a server so that I can use the webapps envyroment. This year one of the applications doesn’t wor because of a Java runtime error that seems to come from the server itself. The issue is the application worked just fine before so now I’m trying to undertand possible causes and solutions to this issue.
Matlab version is 2018a;
The fist part of the erro message is shown below.
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffdcd35696d, pid=7900, tid=0x0000000000001c98
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
#
C
0x00007ffdcd35696d
#
# Core dump written. Default location: C:UsersMATLABWebAppsGuestAppDataLocalMathWorkswebappsservicesmdwassessions868f2753-24fa-47f2-a64f-981cf6d48615hs_err_pid7900.mdmp
#
# An error report file with more information is saved as:
# C:ProgramDataMathWorkswebappsR2018alogshs_error_pid7900.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug. I have an online application in a server so that I can use the webapps envyroment. This year one of the applications doesn’t wor because of a Java runtime error that seems to come from the server itself. The issue is the application worked just fine before so now I’m trying to undertand possible causes and solutions to this issue.
Matlab version is 2018a;
The fist part of the erro message is shown below.
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffdcd35696d, pid=7900, tid=0x0000000000001c98
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
#
C
0x00007ffdcd35696d
#
# Core dump written. Default location: C:UsersMATLABWebAppsGuestAppDataLocalMathWorkswebappsservicesmdwassessions868f2753-24fa-47f2-a64f-981cf6d48615hs_err_pid7900.mdmp
#
# An error report file with more information is saved as:
# C:ProgramDataMathWorkswebappsR2018alogshs_error_pid7900.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug. java, webapps MATLAB Answers — New Questions
Estimate Pose of Moving Camera Mounted on a Robot: How to get the joint angles information for a UR5
Good afternoon,
I would like to find the transformation between a camera mounted on a UR5 and the TCP of this robot.
I’m using the code from the MATLAB example Estimate Pose of Moving Camera Mounted on a Robot but I’m having a problem with the values for the robot’s joint angles. I used the values I obtained from the UR5 register ‘actual_q’. I read this register via an RTDE connection.
When I used the information found in this register with the images taken by my camera, I obtained the following result:
I did some research and discovered that the error was due to the joint robot’s joint angles values I had been given in the code.
In the ‘Real-Time Data Exchange (RTDE) Guide’ for UR5 (https://www.universal-robots.com/articles/ur/interface-communication/real-time-data-exchange-rtde-guide/), it says that ‘actual_q’ is the actual joint position in radians.
I guess I missed a transformation or got the wrong data.
Can you help me understand why this isn’t working?Good afternoon,
I would like to find the transformation between a camera mounted on a UR5 and the TCP of this robot.
I’m using the code from the MATLAB example Estimate Pose of Moving Camera Mounted on a Robot but I’m having a problem with the values for the robot’s joint angles. I used the values I obtained from the UR5 register ‘actual_q’. I read this register via an RTDE connection.
When I used the information found in this register with the images taken by my camera, I obtained the following result:
I did some research and discovered that the error was due to the joint robot’s joint angles values I had been given in the code.
In the ‘Real-Time Data Exchange (RTDE) Guide’ for UR5 (https://www.universal-robots.com/articles/ur/interface-communication/real-time-data-exchange-rtde-guide/), it says that ‘actual_q’ is the actual joint position in radians.
I guess I missed a transformation or got the wrong data.
Can you help me understand why this isn’t working? Good afternoon,
I would like to find the transformation between a camera mounted on a UR5 and the TCP of this robot.
I’m using the code from the MATLAB example Estimate Pose of Moving Camera Mounted on a Robot but I’m having a problem with the values for the robot’s joint angles. I used the values I obtained from the UR5 register ‘actual_q’. I read this register via an RTDE connection.
When I used the information found in this register with the images taken by my camera, I obtained the following result:
I did some research and discovered that the error was due to the joint robot’s joint angles values I had been given in the code.
In the ‘Real-Time Data Exchange (RTDE) Guide’ for UR5 (https://www.universal-robots.com/articles/ur/interface-communication/real-time-data-exchange-rtde-guide/), it says that ‘actual_q’ is the actual joint position in radians.
I guess I missed a transformation or got the wrong data.
Can you help me understand why this isn’t working? ur5, camera MATLAB Answers — New Questions
GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR
GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR example uses:
Satellite Communications Toolbox
Communications Toolbox Support Package for Analog Devices ADALM-PLUTO Radio
I installed these both successfully but when I want to open the example using
openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
It prints following errors:
>> openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
Error using findExample
Example "GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample" not found in "C:Program
FilesMATLABR2022bexamplessatcomexamples.xml".
Error in setupExample (line 6)
metadata = findExample(arg);
Error in openExample (line 30)
[workDir,metadata] = setupExample(exampleId, workDir);
>>
and its saying true that example is present in the directory but not included in example.xml. but why????
secondly I included it in xml file manually but the same error occurred again.GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR example uses:
Satellite Communications Toolbox
Communications Toolbox Support Package for Analog Devices ADALM-PLUTO Radio
I installed these both successfully but when I want to open the example using
openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
It prints following errors:
>> openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
Error using findExample
Example "GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample" not found in "C:Program
FilesMATLABR2022bexamplessatcomexamples.xml".
Error in setupExample (line 6)
metadata = findExample(arg);
Error in openExample (line 30)
[workDir,metadata] = setupExample(exampleId, workDir);
>>
and its saying true that example is present in the directory but not included in example.xml. but why????
secondly I included it in xml file manually but the same error occurred again. GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR example uses:
Satellite Communications Toolbox
Communications Toolbox Support Package for Analog Devices ADALM-PLUTO Radio
I installed these both successfully but when I want to open the example using
openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
It prints following errors:
>> openExample(‘satcom/GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample’)
Error using findExample
Example "GPSReceiverAcquisitionAndTrackingUsingPlutoSDRExample" not found in "C:Program
FilesMATLABR2022bexamplessatcomexamples.xml".
Error in setupExample (line 6)
metadata = findExample(arg);
Error in openExample (line 30)
[workDir,metadata] = setupExample(exampleId, workDir);
>>
and its saying true that example is present in the directory but not included in example.xml. but why????
secondly I included it in xml file manually but the same error occurred again. plutosdr, gps-tranmitter MATLAB Answers — New Questions
I need to correct the script for coloring map
%## Edited so that code runs here
clc;
close all;
clear;
% Read the geological map
% [file, path] = uigetfile(‘*.jpg’, ‘Select the Geological Map File’);
path = ‘./’;
file = ‘Geological map of Mobrun Sulfied.jpg’;
map_image = imread(fullfile(path, file));
% Display the original map
figure;
imshow(map_image);
title(‘Original Map’);
% Convert to RGB if the image is grayscale
if size(map_image, 3) == 1
map_image = cat(3, map_image, map_image, map_image);
end
% Define masks for regions based on RGB values
% Inspect the RGB values of each region using ‘impixelinfo’ or similar
% Example: Rhyolite, Andesite, and Meta-sediments regions
% Replace these thresholds with specific RGB ranges based on your map
ryolite_mask = (map_image(:,:,1) > 200 & map_image(:,:,2) < 100 & map_image(:,:,3) < 100); % Example: Red shades
andesite_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) > 150 & map_image(:,:,3) < 100); % Example: Green shades
meta_sediments_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) < 100 & map_image(:,:,3) > 150); % Example: Blue shades
% Create a copy of the map for coloring
colored_map = map_image;
% Apply colors to the masks
% Rhyolite – Red
colored_map(:,:,1) = colored_map(:,:,1) + uint8(ryolite_mask) * 255; % Red channel
colored_map(:,:,2) = colored_map(:,:,2) – uint8(ryolite_mask) * 255; % Green channel
colored_map(:,:,3) = colored_map(:,:,3) – uint8(ryolite_mask) * 255; % Blue channel
% Andesite – Green
colored_map(:,:,1) = colored_map(:,:,1) – uint8(andesite_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) + uint8(andesite_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) – uint8(andesite_mask) * 255;
% Meta-sediments – Blue
colored_map(:,:,1) = colored_map(:,:,1) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) + uint8(meta_sediments_mask) * 255;
% Display the colored map
figure;
imshow(colored_map);
title(‘Colored Geological Map’);
% Save the colored map
imwrite(colored_map, ‘Colored_Geological_Map_Automatic.jpg’);%## Edited so that code runs here
clc;
close all;
clear;
% Read the geological map
% [file, path] = uigetfile(‘*.jpg’, ‘Select the Geological Map File’);
path = ‘./’;
file = ‘Geological map of Mobrun Sulfied.jpg’;
map_image = imread(fullfile(path, file));
% Display the original map
figure;
imshow(map_image);
title(‘Original Map’);
% Convert to RGB if the image is grayscale
if size(map_image, 3) == 1
map_image = cat(3, map_image, map_image, map_image);
end
% Define masks for regions based on RGB values
% Inspect the RGB values of each region using ‘impixelinfo’ or similar
% Example: Rhyolite, Andesite, and Meta-sediments regions
% Replace these thresholds with specific RGB ranges based on your map
ryolite_mask = (map_image(:,:,1) > 200 & map_image(:,:,2) < 100 & map_image(:,:,3) < 100); % Example: Red shades
andesite_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) > 150 & map_image(:,:,3) < 100); % Example: Green shades
meta_sediments_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) < 100 & map_image(:,:,3) > 150); % Example: Blue shades
% Create a copy of the map for coloring
colored_map = map_image;
% Apply colors to the masks
% Rhyolite – Red
colored_map(:,:,1) = colored_map(:,:,1) + uint8(ryolite_mask) * 255; % Red channel
colored_map(:,:,2) = colored_map(:,:,2) – uint8(ryolite_mask) * 255; % Green channel
colored_map(:,:,3) = colored_map(:,:,3) – uint8(ryolite_mask) * 255; % Blue channel
% Andesite – Green
colored_map(:,:,1) = colored_map(:,:,1) – uint8(andesite_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) + uint8(andesite_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) – uint8(andesite_mask) * 255;
% Meta-sediments – Blue
colored_map(:,:,1) = colored_map(:,:,1) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) + uint8(meta_sediments_mask) * 255;
% Display the colored map
figure;
imshow(colored_map);
title(‘Colored Geological Map’);
% Save the colored map
imwrite(colored_map, ‘Colored_Geological_Map_Automatic.jpg’); %## Edited so that code runs here
clc;
close all;
clear;
% Read the geological map
% [file, path] = uigetfile(‘*.jpg’, ‘Select the Geological Map File’);
path = ‘./’;
file = ‘Geological map of Mobrun Sulfied.jpg’;
map_image = imread(fullfile(path, file));
% Display the original map
figure;
imshow(map_image);
title(‘Original Map’);
% Convert to RGB if the image is grayscale
if size(map_image, 3) == 1
map_image = cat(3, map_image, map_image, map_image);
end
% Define masks for regions based on RGB values
% Inspect the RGB values of each region using ‘impixelinfo’ or similar
% Example: Rhyolite, Andesite, and Meta-sediments regions
% Replace these thresholds with specific RGB ranges based on your map
ryolite_mask = (map_image(:,:,1) > 200 & map_image(:,:,2) < 100 & map_image(:,:,3) < 100); % Example: Red shades
andesite_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) > 150 & map_image(:,:,3) < 100); % Example: Green shades
meta_sediments_mask = (map_image(:,:,1) < 100 & map_image(:,:,2) < 100 & map_image(:,:,3) > 150); % Example: Blue shades
% Create a copy of the map for coloring
colored_map = map_image;
% Apply colors to the masks
% Rhyolite – Red
colored_map(:,:,1) = colored_map(:,:,1) + uint8(ryolite_mask) * 255; % Red channel
colored_map(:,:,2) = colored_map(:,:,2) – uint8(ryolite_mask) * 255; % Green channel
colored_map(:,:,3) = colored_map(:,:,3) – uint8(ryolite_mask) * 255; % Blue channel
% Andesite – Green
colored_map(:,:,1) = colored_map(:,:,1) – uint8(andesite_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) + uint8(andesite_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) – uint8(andesite_mask) * 255;
% Meta-sediments – Blue
colored_map(:,:,1) = colored_map(:,:,1) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,2) = colored_map(:,:,2) – uint8(meta_sediments_mask) * 255;
colored_map(:,:,3) = colored_map(:,:,3) + uint8(meta_sediments_mask) * 255;
% Display the colored map
figure;
imshow(colored_map);
title(‘Colored Geological Map’);
% Save the colored map
imwrite(colored_map, ‘Colored_Geological_Map_Automatic.jpg’); coloring, colormap MATLAB Answers — New Questions
Error evaluating parameter. Dot indexing is not supported for variables of this type.
I’ve learned a simlulink model on file exchange and wish to try using it on my own PMSM model. but after I copy the main blocks in my model it shows up this error :
And here is my own model and parameters command :
I’ve search on the internet and got some little conclution : Unlike me, the exchange model set it’s parameters inside the properties.
So I’ve tried to set the same properties inside my model and even tried to paste it inside my command window but it still won’t work.
Can anyone help solving the problem? I’m new in Matlab Simulink and wish to learn more.I’ve learned a simlulink model on file exchange and wish to try using it on my own PMSM model. but after I copy the main blocks in my model it shows up this error :
And here is my own model and parameters command :
I’ve search on the internet and got some little conclution : Unlike me, the exchange model set it’s parameters inside the properties.
So I’ve tried to set the same properties inside my model and even tried to paste it inside my command window but it still won’t work.
Can anyone help solving the problem? I’m new in Matlab Simulink and wish to learn more. I’ve learned a simlulink model on file exchange and wish to try using it on my own PMSM model. but after I copy the main blocks in my model it shows up this error :
And here is my own model and parameters command :
I’ve search on the internet and got some little conclution : Unlike me, the exchange model set it’s parameters inside the properties.
So I’ve tried to set the same properties inside my model and even tried to paste it inside my command window but it still won’t work.
Can anyone help solving the problem? I’m new in Matlab Simulink and wish to learn more. dot indexing is not supported for variables of this type, error parameters, pmsm MATLAB Answers — New Questions
Matlab cannot connect to the raspberry cameraboard
Hi i’m trying to use my raspberry and the camera to do data acquisition and control with matlab but after the connection to the raspberry, matlab is not connecting to the camera. it’s for a project and without that i can’t do anything.
This is the error i receive with this both lines :
i’ve tried each and the result was the same.
cam = cameraboard(mypi, ‘Resolution’, ‘1280×720’);
cam = mypi.cameraboard;
Warning: Response size for request ID 0xF150 is expected as 4 but received as 0.
> In matlabshared.ioclient/IOProtocol/isReservedRequestID
In matlabshared.ioclient/IOProtocol/getDataDecodePacketExternal
In matlabshared.ioclient/IOProtocol/processBufferedData
In matlabshared.ioclient/IOProtocol/fetchDataPtForUniqueIdFromTransportLayer
In matlabshared.ioclient/IOProtocol/commandResponse
In matlabshared.ioclient/IOProtocol/rawReadInternal
In matlabshared.ioclient/IOProtocol/processCommandQueue
In matlabshared.ioclient/IOProtocol/rawRead
In raspi.internal/LibCamera/open (line 725)
In raspi.internal/LibCamera (line 158)
In raspi.internal/RaspiBase/cameraboard (line 309)
In raspi.internal/RaspiHWSDKController/processInternal (line 1775)
In raspi.internal/RaspiHWSDKController/cameraboard (line 694)
In raspi/cameraboard (line 855)
Cannot connect to the Camera Board.
Caused by:
Index exceeds the number of array elements. Index must not exceed 1.Hi i’m trying to use my raspberry and the camera to do data acquisition and control with matlab but after the connection to the raspberry, matlab is not connecting to the camera. it’s for a project and without that i can’t do anything.
This is the error i receive with this both lines :
i’ve tried each and the result was the same.
cam = cameraboard(mypi, ‘Resolution’, ‘1280×720’);
cam = mypi.cameraboard;
Warning: Response size for request ID 0xF150 is expected as 4 but received as 0.
> In matlabshared.ioclient/IOProtocol/isReservedRequestID
In matlabshared.ioclient/IOProtocol/getDataDecodePacketExternal
In matlabshared.ioclient/IOProtocol/processBufferedData
In matlabshared.ioclient/IOProtocol/fetchDataPtForUniqueIdFromTransportLayer
In matlabshared.ioclient/IOProtocol/commandResponse
In matlabshared.ioclient/IOProtocol/rawReadInternal
In matlabshared.ioclient/IOProtocol/processCommandQueue
In matlabshared.ioclient/IOProtocol/rawRead
In raspi.internal/LibCamera/open (line 725)
In raspi.internal/LibCamera (line 158)
In raspi.internal/RaspiBase/cameraboard (line 309)
In raspi.internal/RaspiHWSDKController/processInternal (line 1775)
In raspi.internal/RaspiHWSDKController/cameraboard (line 694)
In raspi/cameraboard (line 855)
Cannot connect to the Camera Board.
Caused by:
Index exceeds the number of array elements. Index must not exceed 1. Hi i’m trying to use my raspberry and the camera to do data acquisition and control with matlab but after the connection to the raspberry, matlab is not connecting to the camera. it’s for a project and without that i can’t do anything.
This is the error i receive with this both lines :
i’ve tried each and the result was the same.
cam = cameraboard(mypi, ‘Resolution’, ‘1280×720’);
cam = mypi.cameraboard;
Warning: Response size for request ID 0xF150 is expected as 4 but received as 0.
> In matlabshared.ioclient/IOProtocol/isReservedRequestID
In matlabshared.ioclient/IOProtocol/getDataDecodePacketExternal
In matlabshared.ioclient/IOProtocol/processBufferedData
In matlabshared.ioclient/IOProtocol/fetchDataPtForUniqueIdFromTransportLayer
In matlabshared.ioclient/IOProtocol/commandResponse
In matlabshared.ioclient/IOProtocol/rawReadInternal
In matlabshared.ioclient/IOProtocol/processCommandQueue
In matlabshared.ioclient/IOProtocol/rawRead
In raspi.internal/LibCamera/open (line 725)
In raspi.internal/LibCamera (line 158)
In raspi.internal/RaspiBase/cameraboard (line 309)
In raspi.internal/RaspiHWSDKController/processInternal (line 1775)
In raspi.internal/RaspiHWSDKController/cameraboard (line 694)
In raspi/cameraboard (line 855)
Cannot connect to the Camera Board.
Caused by:
Index exceeds the number of array elements. Index must not exceed 1. matlab, raspberry, cameraboard, raspberrycamera MATLAB Answers — New Questions
How does c2d(…,method) compute the matrices Ad and Bd for both ‘zoh’ and ‘foh’ as method?
Given a continuousTimeStateSpaceModel comprising the matrices A, B, C, and D (albeit D = 0) and given a sample time Ts, how does discreteTimeStateSpaceModel = c2d(continuousTimeStateSpaceModel,Ts,method) comprising the matrices Ad, Bd, C, and D work for both ‘zoh’ and ‘foh’ as method? As stated, I guess, C and D will remain unchanged in both cases, but how are Ad and Bd computed in each case?
i.e.
‘zoh’: Ad = …, Bd = …
‘foh’: Ad = …, Bd = …
Thanks in advance!Given a continuousTimeStateSpaceModel comprising the matrices A, B, C, and D (albeit D = 0) and given a sample time Ts, how does discreteTimeStateSpaceModel = c2d(continuousTimeStateSpaceModel,Ts,method) comprising the matrices Ad, Bd, C, and D work for both ‘zoh’ and ‘foh’ as method? As stated, I guess, C and D will remain unchanged in both cases, but how are Ad and Bd computed in each case?
i.e.
‘zoh’: Ad = …, Bd = …
‘foh’: Ad = …, Bd = …
Thanks in advance! Given a continuousTimeStateSpaceModel comprising the matrices A, B, C, and D (albeit D = 0) and given a sample time Ts, how does discreteTimeStateSpaceModel = c2d(continuousTimeStateSpaceModel,Ts,method) comprising the matrices Ad, Bd, C, and D work for both ‘zoh’ and ‘foh’ as method? As stated, I guess, C and D will remain unchanged in both cases, but how are Ad and Bd computed in each case?
i.e.
‘zoh’: Ad = …, Bd = …
‘foh’: Ad = …, Bd = …
Thanks in advance! matlab, c2d, zoh, foh, discretization, control, system MATLAB Answers — New Questions
Cannot read csv with readtable (Unrecognized field name “text”)
Hi All,
I’m trying to read some csv data but saw the following error, for which I had absolutely no clue… Could anyone kindly help?
aaa.csv is just a simple dummy dataset I created with excel for the sake of testing.
Error from matlab:
aaa = readtable(‘G:My DriveProject_GDrivedataaaa.csv’);
Error using readtable (line 517)
Unrecognized field name "text".
Many thanks
MinHi All,
I’m trying to read some csv data but saw the following error, for which I had absolutely no clue… Could anyone kindly help?
aaa.csv is just a simple dummy dataset I created with excel for the sake of testing.
Error from matlab:
aaa = readtable(‘G:My DriveProject_GDrivedataaaa.csv’);
Error using readtable (line 517)
Unrecognized field name "text".
Many thanks
Min Hi All,
I’m trying to read some csv data but saw the following error, for which I had absolutely no clue… Could anyone kindly help?
aaa.csv is just a simple dummy dataset I created with excel for the sake of testing.
Error from matlab:
aaa = readtable(‘G:My DriveProject_GDrivedataaaa.csv’);
Error using readtable (line 517)
Unrecognized field name "text".
Many thanks
Min readtable, csv MATLAB Answers — New Questions
Question about logical indexing
I am relatively new to MatLab and am having a tough time with organizing a set of data for work. I have the data in two separate tables. The first table is a master list of traps and cumulative catch per trap with variable names: Year (using integers in place of actual years), Site (again, integers instead of site names), Week (integers again), Trap (integer – unique Tag ID), Catch (response measured – count data). Example below:
Year Site Week Trap Catch
____ ____ ____ ____ _____
1 1 1 29 9
1 1 1 28 0
1 1 1 18 4
1 1 1 27 0
1 1 1 622 19
1 1 1 10 0
1 1 1 17 10
The second table is the raw data describing each individual animal collected in each trap. Example with variable names below:
Year Week Site Trap Sex CL Legal Greater60
____ ____ ____ ____ ___ ____ _____ _________
1 1 2 41 2 71.1 0 1
1 1 2 41 2 50 0 0
1 1 2 42 2 73.9 0 1
1 1 2 42 2 57.3 0 0
1 1 2 42 2 61.5 0 1
Year, Week, Site, and Trap all appear in both tables. In table two. Catch, in table 1 is the total number of animals caught by each unique trap in a year, week, site combination. Legal and Greater60 in table two are binary responses based on the size of the animal (1 = true, 0 = false). All traps in Table two appear in table one, but if a trap did not catch anything, it does not appear in table two.
My goal is to use logical indexing to add two columns (Legal, Greater60) to Table 1 after Catch wherein I have a sum of the Legal and Greater60 values in Table two for each trap in each year, week, site combination.
I hope that makes sense. Any help is much appreciated.I am relatively new to MatLab and am having a tough time with organizing a set of data for work. I have the data in two separate tables. The first table is a master list of traps and cumulative catch per trap with variable names: Year (using integers in place of actual years), Site (again, integers instead of site names), Week (integers again), Trap (integer – unique Tag ID), Catch (response measured – count data). Example below:
Year Site Week Trap Catch
____ ____ ____ ____ _____
1 1 1 29 9
1 1 1 28 0
1 1 1 18 4
1 1 1 27 0
1 1 1 622 19
1 1 1 10 0
1 1 1 17 10
The second table is the raw data describing each individual animal collected in each trap. Example with variable names below:
Year Week Site Trap Sex CL Legal Greater60
____ ____ ____ ____ ___ ____ _____ _________
1 1 2 41 2 71.1 0 1
1 1 2 41 2 50 0 0
1 1 2 42 2 73.9 0 1
1 1 2 42 2 57.3 0 0
1 1 2 42 2 61.5 0 1
Year, Week, Site, and Trap all appear in both tables. In table two. Catch, in table 1 is the total number of animals caught by each unique trap in a year, week, site combination. Legal and Greater60 in table two are binary responses based on the size of the animal (1 = true, 0 = false). All traps in Table two appear in table one, but if a trap did not catch anything, it does not appear in table two.
My goal is to use logical indexing to add two columns (Legal, Greater60) to Table 1 after Catch wherein I have a sum of the Legal and Greater60 values in Table two for each trap in each year, week, site combination.
I hope that makes sense. Any help is much appreciated. I am relatively new to MatLab and am having a tough time with organizing a set of data for work. I have the data in two separate tables. The first table is a master list of traps and cumulative catch per trap with variable names: Year (using integers in place of actual years), Site (again, integers instead of site names), Week (integers again), Trap (integer – unique Tag ID), Catch (response measured – count data). Example below:
Year Site Week Trap Catch
____ ____ ____ ____ _____
1 1 1 29 9
1 1 1 28 0
1 1 1 18 4
1 1 1 27 0
1 1 1 622 19
1 1 1 10 0
1 1 1 17 10
The second table is the raw data describing each individual animal collected in each trap. Example with variable names below:
Year Week Site Trap Sex CL Legal Greater60
____ ____ ____ ____ ___ ____ _____ _________
1 1 2 41 2 71.1 0 1
1 1 2 41 2 50 0 0
1 1 2 42 2 73.9 0 1
1 1 2 42 2 57.3 0 0
1 1 2 42 2 61.5 0 1
Year, Week, Site, and Trap all appear in both tables. In table two. Catch, in table 1 is the total number of animals caught by each unique trap in a year, week, site combination. Legal and Greater60 in table two are binary responses based on the size of the animal (1 = true, 0 = false). All traps in Table two appear in table one, but if a trap did not catch anything, it does not appear in table two.
My goal is to use logical indexing to add two columns (Legal, Greater60) to Table 1 after Catch wherein I have a sum of the Legal and Greater60 values in Table two for each trap in each year, week, site combination.
I hope that makes sense. Any help is much appreciated. logical indexing, data organization MATLAB Answers — New Questions
How to import external c types with namespaces?
I try to import external c header files to my simulink model.
I am using the function ImportExternalCTypes() (Matlab2021b) to import the header file.
Call of the function:
Simulink.importExternalCTypes(‘test.h’, ‘Language’, ‘C++’, ‘Overwrite’, ‘on’, ‘DataDictionary’, ‘Types.sldd’)
Content of the header file test.h:
#include <string>
#include <vector>
#include <stdexcept>
namespace System {
namespace Command {
enum Type {
On,
Off
};
}
enum class Subystem {
Stop,
Start
};
The enumeration within the namespace will be ignored.
Only the enumeration Subystem will be added to the Data Dictionary.
Is there a wag that Matlab recognizes the Enumeration within the namespace?
I get an auto generated header file with the namespaces. All Enumerations are defined within namespaces in the original header file.I try to import external c header files to my simulink model.
I am using the function ImportExternalCTypes() (Matlab2021b) to import the header file.
Call of the function:
Simulink.importExternalCTypes(‘test.h’, ‘Language’, ‘C++’, ‘Overwrite’, ‘on’, ‘DataDictionary’, ‘Types.sldd’)
Content of the header file test.h:
#include <string>
#include <vector>
#include <stdexcept>
namespace System {
namespace Command {
enum Type {
On,
Off
};
}
enum class Subystem {
Stop,
Start
};
The enumeration within the namespace will be ignored.
Only the enumeration Subystem will be added to the Data Dictionary.
Is there a wag that Matlab recognizes the Enumeration within the namespace?
I get an auto generated header file with the namespaces. All Enumerations are defined within namespaces in the original header file. I try to import external c header files to my simulink model.
I am using the function ImportExternalCTypes() (Matlab2021b) to import the header file.
Call of the function:
Simulink.importExternalCTypes(‘test.h’, ‘Language’, ‘C++’, ‘Overwrite’, ‘on’, ‘DataDictionary’, ‘Types.sldd’)
Content of the header file test.h:
#include <string>
#include <vector>
#include <stdexcept>
namespace System {
namespace Command {
enum Type {
On,
Off
};
}
enum class Subystem {
Stop,
Start
};
The enumeration within the namespace will be ignored.
Only the enumeration Subystem will be added to the Data Dictionary.
Is there a wag that Matlab recognizes the Enumeration within the namespace?
I get an auto generated header file with the namespaces. All Enumerations are defined within namespaces in the original header file. importexternalctypes, header, import, c++ MATLAB Answers — New Questions
Ctrl-Shift-X not working
I want to use keyboard shortcut Ctrl-Shift-X for commenting out my simulink block. But when I press the shortcut commenting out is not working. How to fix that??I want to use keyboard shortcut Ctrl-Shift-X for commenting out my simulink block. But when I press the shortcut commenting out is not working. How to fix that?? I want to use keyboard shortcut Ctrl-Shift-X for commenting out my simulink block. But when I press the shortcut commenting out is not working. How to fix that?? ctrl shift x, comment, simulink MATLAB Answers — New Questions