Tag Archives: matlab
Human Detection using YOLOV3 with own Weights
Hi everyone! I am trying to detect humans using yolov3 weights. Right now, I am trying to detect using an image but later I am going to use a camera to detect humans. I don’t know if this is possible using my own weights with my config file.Hi everyone! I am trying to detect humans using yolov3 weights. Right now, I am trying to detect using an image but later I am going to use a camera to detect humans. I don’t know if this is possible using my own weights with my config file. Hi everyone! I am trying to detect humans using yolov3 weights. Right now, I am trying to detect using an image but later I am going to use a camera to detect humans. I don’t know if this is possible using my own weights with my config file. human detection, yolov3, object detection MATLAB Answers — New Questions
Warning: Block diagram ‘XYZ’ contains disabled library links.
After deleting a model from library, I am trying to save that library, but I am coming accross a warning message as follows:
Warning: Block diagram ‘XYZ’ contains disabled library links. Use Model Advisor to find the disabled links in non-library models. The diagram has been saved but may not contain what you intended.
I can see that model advisor is able to help to resolve the Disabled library links but how can it be used to identify disabled links in non-library models.
Please suggest on this.
Regards,
Bhavnish.After deleting a model from library, I am trying to save that library, but I am coming accross a warning message as follows:
Warning: Block diagram ‘XYZ’ contains disabled library links. Use Model Advisor to find the disabled links in non-library models. The diagram has been saved but may not contain what you intended.
I can see that model advisor is able to help to resolve the Disabled library links but how can it be used to identify disabled links in non-library models.
Please suggest on this.
Regards,
Bhavnish. After deleting a model from library, I am trying to save that library, but I am coming accross a warning message as follows:
Warning: Block diagram ‘XYZ’ contains disabled library links. Use Model Advisor to find the disabled links in non-library models. The diagram has been saved but may not contain what you intended.
I can see that model advisor is able to help to resolve the Disabled library links but how can it be used to identify disabled links in non-library models.
Please suggest on this.
Regards,
Bhavnish. disabled library links MATLAB Answers — New Questions
deep learning architecture can explain how connected layers and filters
some one can explain how this connections fit each to previous stage
layers = [ imageInputLayer([28 28 1])
convolution2dLayer(5,20)
reluLayer
maxPooling2dLayer(2, ‘Stride’, 2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer() ]some one can explain how this connections fit each to previous stage
layers = [ imageInputLayer([28 28 1])
convolution2dLayer(5,20)
reluLayer
maxPooling2dLayer(2, ‘Stride’, 2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer() ] some one can explain how this connections fit each to previous stage
layers = [ imageInputLayer([28 28 1])
convolution2dLayer(5,20)
reluLayer
maxPooling2dLayer(2, ‘Stride’, 2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer() ] deep learning MATLAB Answers — New Questions
unable to incorporate own design Loss function in r2024a
Switching from r2023b to r2024 I made some changes in my Net (CNN). e.g. modified input/output and replace RegressionLayer with SoftmaxLayer, using trainnet function, etc.
I expected better performance, perspective compatibility (RegressionLayre is not more recommended) and have a vision of my Net optimization with use of Prune approach etc.
To the contrary to the previous version I am not able to involve my own Loss function (as it was done in previous version).
The (siplified) code is below, the used synthax was inspired by example:
https://www.mathworks.com/matlabcentral/answers/2100631-how-can-i-define-a-custom-loss-function-using-trainnet
The error message is:
Error using trainnet (line 46)
Error calling function during training.
Error in callMyLoss (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Caused by:
Error using myOwnLoss
The specified superclass ‘nnet.layer.softmaxLayer’ contains a parse error, cannot be found on MATLAB’s
search
path, or is shadowed by another file with the same name.
Error in callMyLoss>@(Y,target)myOwnLoss(name,Y,target) (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Error in nnet.internal.cnn.util.UserCodeException.fevalUserCode (line 11)
[varargout{1:nargout}] = feval(F, varargin{:});
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof=========================
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof=========================Switching from r2023b to r2024 I made some changes in my Net (CNN). e.g. modified input/output and replace RegressionLayer with SoftmaxLayer, using trainnet function, etc.
I expected better performance, perspective compatibility (RegressionLayre is not more recommended) and have a vision of my Net optimization with use of Prune approach etc.
To the contrary to the previous version I am not able to involve my own Loss function (as it was done in previous version).
The (siplified) code is below, the used synthax was inspired by example:
https://www.mathworks.com/matlabcentral/answers/2100631-how-can-i-define-a-custom-loss-function-using-trainnet
The error message is:
Error using trainnet (line 46)
Error calling function during training.
Error in callMyLoss (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Caused by:
Error using myOwnLoss
The specified superclass ‘nnet.layer.softmaxLayer’ contains a parse error, cannot be found on MATLAB’s
search
path, or is shadowed by another file with the same name.
Error in callMyLoss>@(Y,target)myOwnLoss(name,Y,target) (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Error in nnet.internal.cnn.util.UserCodeException.fevalUserCode (line 11)
[varargout{1:nargout}] = feval(F, varargin{:});
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof=========================
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof========================= Switching from r2023b to r2024 I made some changes in my Net (CNN). e.g. modified input/output and replace RegressionLayer with SoftmaxLayer, using trainnet function, etc.
I expected better performance, perspective compatibility (RegressionLayre is not more recommended) and have a vision of my Net optimization with use of Prune approach etc.
To the contrary to the previous version I am not able to involve my own Loss function (as it was done in previous version).
The (siplified) code is below, the used synthax was inspired by example:
https://www.mathworks.com/matlabcentral/answers/2100631-how-can-i-define-a-custom-loss-function-using-trainnet
The error message is:
Error using trainnet (line 46)
Error calling function during training.
Error in callMyLoss (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Caused by:
Error using myOwnLoss
The specified superclass ‘nnet.layer.softmaxLayer’ contains a parse error, cannot be found on MATLAB’s
search
path, or is shadowed by another file with the same name.
Error in callMyLoss>@(Y,target)myOwnLoss(name,Y,target) (line 55)
myTrainedNet = trainnet(Y,target,net, @(Y,target) myOwnLoss(name,Y,target),options);
Error in nnet.internal.cnn.util.UserCodeException.fevalUserCode (line 11)
[varargout{1:nargout}] = feval(F, varargin{:});
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof=========================
classdef myOwnLoss < nnet.layer.softmaxLayer
% own Loss
methods
%function layer = sseClassificationLayer(name)
function layer = myOwnLoss(name)
% layer = sseClassificationLayer(name) creates a sum of squares
% error classification layer and specifies the layer name.
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = ‘my own Loss v.2024a’;
end
function loss = forwardLoss(layer, Y, T)
%%% function loss = forwardLoss(Yo, To)
% loss = forwardLoss(layer, Y, T) returns the Tdiff loss between
% the predictions Y and the training targets T.
disp("myLoss");
aa=1;
% just something very simple
loss = sum(Y-T,’all’);
end
% original backwardLoss
function dX = backwardLoss(layer, Y, T)
numObservations = size( Y, 3);
dX = (Y – T)./numObservations;
end
end
end
%=======================eof========================= loss function, trainnet MATLAB Answers — New Questions
HELP Canonical Huffman coding
Hi, can some one share the source code for Canonical Huffman?
Thank you…Hi, can some one share the source code for Canonical Huffman?
Thank you… Hi, can some one share the source code for Canonical Huffman?
Thank you… huffman, canonical, image compressing, entropy MATLAB Answers — New Questions
Simulink thermal coppling problem
I have this problem where i seem to have some thermal coppling of my Tank(G-TL) with my Constant Volume Chamber. Yet there shouldnt be anything that does effect the temperature in my Constant Volume Chamber i still have something definitely influencing it. When I only simulate the outflow of my Constant Volume Chamber (pink) filled with N2 with a start value of 300 bar and a starting temperature of 300 Kelvin, i get a temperature of 267 Kelvin at the point my Chamber pressure dropped down to 200 bar. But if I simulate the whole circuit (screenshot) i get a different temperature after i dropped down to 200 bar in my Constant Volume Chamber depending on the settings i set my Tank(G-TL) (pink+yellow) on. It would be very nice if someone has an idea what could cause this effect of the temperature behaviour of my Constant Volume Chamber in this Simulink modell?I have this problem where i seem to have some thermal coppling of my Tank(G-TL) with my Constant Volume Chamber. Yet there shouldnt be anything that does effect the temperature in my Constant Volume Chamber i still have something definitely influencing it. When I only simulate the outflow of my Constant Volume Chamber (pink) filled with N2 with a start value of 300 bar and a starting temperature of 300 Kelvin, i get a temperature of 267 Kelvin at the point my Chamber pressure dropped down to 200 bar. But if I simulate the whole circuit (screenshot) i get a different temperature after i dropped down to 200 bar in my Constant Volume Chamber depending on the settings i set my Tank(G-TL) (pink+yellow) on. It would be very nice if someone has an idea what could cause this effect of the temperature behaviour of my Constant Volume Chamber in this Simulink modell? I have this problem where i seem to have some thermal coppling of my Tank(G-TL) with my Constant Volume Chamber. Yet there shouldnt be anything that does effect the temperature in my Constant Volume Chamber i still have something definitely influencing it. When I only simulate the outflow of my Constant Volume Chamber (pink) filled with N2 with a start value of 300 bar and a starting temperature of 300 Kelvin, i get a temperature of 267 Kelvin at the point my Chamber pressure dropped down to 200 bar. But if I simulate the whole circuit (screenshot) i get a different temperature after i dropped down to 200 bar in my Constant Volume Chamber depending on the settings i set my Tank(G-TL) (pink+yellow) on. It would be very nice if someone has an idea what could cause this effect of the temperature behaviour of my Constant Volume Chamber in this Simulink modell? simulink, simscape MATLAB Answers — New Questions
Unique function to return last duplicate value
Hi there,
Is there a way I can use the ‘unique’ function to return the last duplicate value instead of the first one? Refer to the images attached for clarity. Essentially I’m using
"[Sp_Au,ix] = unique(Data.SetPoint, ‘stable’);
DataE = Data(ix,:);"
to retireve the unique values as per the SetPoint column and save it into ‘DataE’, but instead of it starting at rows that correspond to the first "10", I want it to retrieve the last "10" row just before it starts increasing. Is there a way to do that?
So from table Data, instead of it taking rows (1,6,7,8,…etc), I want it export rows (5,6,7,8,9,…etc). So from the last duplicated value. Hope that makes sense.Hi there,
Is there a way I can use the ‘unique’ function to return the last duplicate value instead of the first one? Refer to the images attached for clarity. Essentially I’m using
"[Sp_Au,ix] = unique(Data.SetPoint, ‘stable’);
DataE = Data(ix,:);"
to retireve the unique values as per the SetPoint column and save it into ‘DataE’, but instead of it starting at rows that correspond to the first "10", I want it to retrieve the last "10" row just before it starts increasing. Is there a way to do that?
So from table Data, instead of it taking rows (1,6,7,8,…etc), I want it export rows (5,6,7,8,9,…etc). So from the last duplicated value. Hope that makes sense. Hi there,
Is there a way I can use the ‘unique’ function to return the last duplicate value instead of the first one? Refer to the images attached for clarity. Essentially I’m using
"[Sp_Au,ix] = unique(Data.SetPoint, ‘stable’);
DataE = Data(ix,:);"
to retireve the unique values as per the SetPoint column and save it into ‘DataE’, but instead of it starting at rows that correspond to the first "10", I want it to retrieve the last "10" row just before it starts increasing. Is there a way to do that?
So from table Data, instead of it taking rows (1,6,7,8,…etc), I want it export rows (5,6,7,8,9,…etc). So from the last duplicated value. Hope that makes sense. unique, data MATLAB Answers — New Questions
How to identify duplicate rows between tables
I’m using R2020b, and I want to set up a master table for appending new data to – and as part of this I want to identify any duplicate rows in the new, incoming table to filter them out before appending. Ideally, the master table will live in a related directory in a .mat file, and the new data will be read in directly from a set-name, set-location .csv using e.g.
fullname = fullfile(‘relativepath’,’newdata.csv’);
% grab column headers from input sheet
opts = detectImportOptions(fullname);
% set all variable types to categorical
opts.VariableTypes(:) = {‘categorical’};
% read in new data
T = readtable(fullname,opts);
% make any modifications to new data headers to match old data
T = renamevars(T,"NewLabel","OldLabel");
% clean new table headers to match originally-wizard-imported headers (I’d ask why these exhibit different behaviour, but that’s a separate tragedy, and this current fix works – I think)
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘ ‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘(‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘)’, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘_’, ”);
I found the solution suggested here: https://au.mathworks.com/matlabcentral/answers/514921-finding-identical-rows-in-2-tables, but having done a quick test via:
foo = T(str2double(string(T.Year))<1943,:); % not my actual query, but structurally the same; this gave me ~40% of my original data
bar = T(str2double(string(T.Year))>1941,:); % similar, gave me ~70% of the original data
baz = ismember(foo,bar); % similar, gives the overlap for 1 particular year (should be about 14% of my original data)
blah = T(str2double(string(T.Year))==1942,:); % to directly extract the number of rows I am looking for
sum(baz) % What I expect here is the number of rows in the overlap
ans =
0
I found that ismember was not finding any duplicates (which were there by construction).
Note: due to categorical data I actually used T(str2double(string(T.Year))…)
Replacing
baz = ismember(foo,bar,’rows’);
sum(baz)
ans =
0
results in the same not finding any duplicates. Using double quotes "rows" does not change the behaviour.
On the other hand, using the function to assess single variables gives the expected behaviour (to some degree):
testest = ismember(foo.var1,bar.var1)
sum(testest)
The sum is now non-zero, and (because single variables are repeated more often than their combinations) gives more like 30% of the original data, which seems reasonable (the number of unique entries in the original set in that variable was about 40% of the total).
I guess I could create a logical index based on the product of multiple calls of this kind, but that seems rather… inefficient… and sensitive to the exact construction of the table/variables used in the filter. I’d rather have a generic solution for full table rows that will be robust if the overall table changes over the long term (or if/when I functionalise the code and use it for other work). Whilst most of the time, a couple of key variables can be used to identify unique rows, occasionally more information is required to distinguish pathological cases. I will probably use this approach if a more elegant solution doesn’t appear, though, and put some thought into which groups of variables are 100% correlated (and therefore useless for this distinction) to cut down the Boolean product.
I could also throw good coding practice to the winds and just write two nested loops (one for rows, one for variables) and exhaustively test every combination, but I suspect that would be even less efficient (although I wonder whether the scaling order would be the same given the nature of the comparisons required).
If it is pertinent, I imported all (>25) data columns from a .csv file as categorical variables. The original data before that were a mix of number and general columns from an Excel sheet; I could have used any or all of {double,string,categorical,datetime} to store the various variables, but there are some data which are best stored as categorical to avoid character trimming and consequent data cleaning / returning to original state steps.
Digging further, I also found this: https://au.mathworks.com/matlabcentral/answers/1775400-how-do-i-find-all-indexes-of-duplicate-names-in-a-table-column-then-compare-the-row-values-for-each which appears to imply that ismember should have the functionality I need here.
Similarly, methods using unique (see e.g. https://au.mathworks.com/matlabcentral/answers/1999193-find-duplicated-rows-in-matlab-without-for-loop or https://au.mathworks.com/matlabcentral/answers/1571588-table-find-duplicate-rows-double-char-datetime or https://au.mathworks.com/matlabcentral/answers/305987-identify-duplicate-rows-in-a-matrix) give:
size(unique([foo;bar],’rows’),1) == size(foo,1)+size(bar,1)
ans =
logical
1
instead of the expected 0 due to the lower amount of actual full-row matches. (Same for "rows" again.)
I’ve also looked into outerjoin/join/innerjoin, but those don’t seem to remove duplicates like I need.I’m using R2020b, and I want to set up a master table for appending new data to – and as part of this I want to identify any duplicate rows in the new, incoming table to filter them out before appending. Ideally, the master table will live in a related directory in a .mat file, and the new data will be read in directly from a set-name, set-location .csv using e.g.
fullname = fullfile(‘relativepath’,’newdata.csv’);
% grab column headers from input sheet
opts = detectImportOptions(fullname);
% set all variable types to categorical
opts.VariableTypes(:) = {‘categorical’};
% read in new data
T = readtable(fullname,opts);
% make any modifications to new data headers to match old data
T = renamevars(T,"NewLabel","OldLabel");
% clean new table headers to match originally-wizard-imported headers (I’d ask why these exhibit different behaviour, but that’s a separate tragedy, and this current fix works – I think)
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘ ‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘(‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘)’, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘_’, ”);
I found the solution suggested here: https://au.mathworks.com/matlabcentral/answers/514921-finding-identical-rows-in-2-tables, but having done a quick test via:
foo = T(str2double(string(T.Year))<1943,:); % not my actual query, but structurally the same; this gave me ~40% of my original data
bar = T(str2double(string(T.Year))>1941,:); % similar, gave me ~70% of the original data
baz = ismember(foo,bar); % similar, gives the overlap for 1 particular year (should be about 14% of my original data)
blah = T(str2double(string(T.Year))==1942,:); % to directly extract the number of rows I am looking for
sum(baz) % What I expect here is the number of rows in the overlap
ans =
0
I found that ismember was not finding any duplicates (which were there by construction).
Note: due to categorical data I actually used T(str2double(string(T.Year))…)
Replacing
baz = ismember(foo,bar,’rows’);
sum(baz)
ans =
0
results in the same not finding any duplicates. Using double quotes "rows" does not change the behaviour.
On the other hand, using the function to assess single variables gives the expected behaviour (to some degree):
testest = ismember(foo.var1,bar.var1)
sum(testest)
The sum is now non-zero, and (because single variables are repeated more often than their combinations) gives more like 30% of the original data, which seems reasonable (the number of unique entries in the original set in that variable was about 40% of the total).
I guess I could create a logical index based on the product of multiple calls of this kind, but that seems rather… inefficient… and sensitive to the exact construction of the table/variables used in the filter. I’d rather have a generic solution for full table rows that will be robust if the overall table changes over the long term (or if/when I functionalise the code and use it for other work). Whilst most of the time, a couple of key variables can be used to identify unique rows, occasionally more information is required to distinguish pathological cases. I will probably use this approach if a more elegant solution doesn’t appear, though, and put some thought into which groups of variables are 100% correlated (and therefore useless for this distinction) to cut down the Boolean product.
I could also throw good coding practice to the winds and just write two nested loops (one for rows, one for variables) and exhaustively test every combination, but I suspect that would be even less efficient (although I wonder whether the scaling order would be the same given the nature of the comparisons required).
If it is pertinent, I imported all (>25) data columns from a .csv file as categorical variables. The original data before that were a mix of number and general columns from an Excel sheet; I could have used any or all of {double,string,categorical,datetime} to store the various variables, but there are some data which are best stored as categorical to avoid character trimming and consequent data cleaning / returning to original state steps.
Digging further, I also found this: https://au.mathworks.com/matlabcentral/answers/1775400-how-do-i-find-all-indexes-of-duplicate-names-in-a-table-column-then-compare-the-row-values-for-each which appears to imply that ismember should have the functionality I need here.
Similarly, methods using unique (see e.g. https://au.mathworks.com/matlabcentral/answers/1999193-find-duplicated-rows-in-matlab-without-for-loop or https://au.mathworks.com/matlabcentral/answers/1571588-table-find-duplicate-rows-double-char-datetime or https://au.mathworks.com/matlabcentral/answers/305987-identify-duplicate-rows-in-a-matrix) give:
size(unique([foo;bar],’rows’),1) == size(foo,1)+size(bar,1)
ans =
logical
1
instead of the expected 0 due to the lower amount of actual full-row matches. (Same for "rows" again.)
I’ve also looked into outerjoin/join/innerjoin, but those don’t seem to remove duplicates like I need. I’m using R2020b, and I want to set up a master table for appending new data to – and as part of this I want to identify any duplicate rows in the new, incoming table to filter them out before appending. Ideally, the master table will live in a related directory in a .mat file, and the new data will be read in directly from a set-name, set-location .csv using e.g.
fullname = fullfile(‘relativepath’,’newdata.csv’);
% grab column headers from input sheet
opts = detectImportOptions(fullname);
% set all variable types to categorical
opts.VariableTypes(:) = {‘categorical’};
% read in new data
T = readtable(fullname,opts);
% make any modifications to new data headers to match old data
T = renamevars(T,"NewLabel","OldLabel");
% clean new table headers to match originally-wizard-imported headers (I’d ask why these exhibit different behaviour, but that’s a separate tragedy, and this current fix works – I think)
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘ ‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘(‘, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘)’, ”);
T.Properties.VariableNames = regexprep(T.Properties.VariableNames, ‘_’, ”);
I found the solution suggested here: https://au.mathworks.com/matlabcentral/answers/514921-finding-identical-rows-in-2-tables, but having done a quick test via:
foo = T(str2double(string(T.Year))<1943,:); % not my actual query, but structurally the same; this gave me ~40% of my original data
bar = T(str2double(string(T.Year))>1941,:); % similar, gave me ~70% of the original data
baz = ismember(foo,bar); % similar, gives the overlap for 1 particular year (should be about 14% of my original data)
blah = T(str2double(string(T.Year))==1942,:); % to directly extract the number of rows I am looking for
sum(baz) % What I expect here is the number of rows in the overlap
ans =
0
I found that ismember was not finding any duplicates (which were there by construction).
Note: due to categorical data I actually used T(str2double(string(T.Year))…)
Replacing
baz = ismember(foo,bar,’rows’);
sum(baz)
ans =
0
results in the same not finding any duplicates. Using double quotes "rows" does not change the behaviour.
On the other hand, using the function to assess single variables gives the expected behaviour (to some degree):
testest = ismember(foo.var1,bar.var1)
sum(testest)
The sum is now non-zero, and (because single variables are repeated more often than their combinations) gives more like 30% of the original data, which seems reasonable (the number of unique entries in the original set in that variable was about 40% of the total).
I guess I could create a logical index based on the product of multiple calls of this kind, but that seems rather… inefficient… and sensitive to the exact construction of the table/variables used in the filter. I’d rather have a generic solution for full table rows that will be robust if the overall table changes over the long term (or if/when I functionalise the code and use it for other work). Whilst most of the time, a couple of key variables can be used to identify unique rows, occasionally more information is required to distinguish pathological cases. I will probably use this approach if a more elegant solution doesn’t appear, though, and put some thought into which groups of variables are 100% correlated (and therefore useless for this distinction) to cut down the Boolean product.
I could also throw good coding practice to the winds and just write two nested loops (one for rows, one for variables) and exhaustively test every combination, but I suspect that would be even less efficient (although I wonder whether the scaling order would be the same given the nature of the comparisons required).
If it is pertinent, I imported all (>25) data columns from a .csv file as categorical variables. The original data before that were a mix of number and general columns from an Excel sheet; I could have used any or all of {double,string,categorical,datetime} to store the various variables, but there are some data which are best stored as categorical to avoid character trimming and consequent data cleaning / returning to original state steps.
Digging further, I also found this: https://au.mathworks.com/matlabcentral/answers/1775400-how-do-i-find-all-indexes-of-duplicate-names-in-a-table-column-then-compare-the-row-values-for-each which appears to imply that ismember should have the functionality I need here.
Similarly, methods using unique (see e.g. https://au.mathworks.com/matlabcentral/answers/1999193-find-duplicated-rows-in-matlab-without-for-loop or https://au.mathworks.com/matlabcentral/answers/1571588-table-find-duplicate-rows-double-char-datetime or https://au.mathworks.com/matlabcentral/answers/305987-identify-duplicate-rows-in-a-matrix) give:
size(unique([foo;bar],’rows’),1) == size(foo,1)+size(bar,1)
ans =
logical
1
instead of the expected 0 due to the lower amount of actual full-row matches. (Same for "rows" again.)
I’ve also looked into outerjoin/join/innerjoin, but those don’t seem to remove duplicates like I need. table, ismember, rows, duplicate MATLAB Answers — New Questions
PSpice matlab co-simulation
Can someone help me with this problem?
After I configured the co-simulation environment, I clicked the run button in simulink, and finally the matlab crash task box popped up. The crash log file is as follows:
——————————————————————————–
Access violation detected at 2024-08-23 11:04:18 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA GeForce RTX 2060 Version 27.21.14.6109 (2020-12-31)
Graphics card 2 : Advanced Micro Devices, Inc. ( 0x1002 ) AMD Radeon(TM) Graphics Version 31.0.14046.0 (2023-3-29)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 6257193
MATLAB Root : E:
MATLAB Version : 9.13.0.2049777 (R2022b)
OpenGL : hardware
Operating System : Microsoft Windows 10 专业版
Process ID : 4572
Processor ID : x86 Family 23 Model 96 Stepping 1, AuthenticAMD
Session Key : 48ca539b-11d4-4b26-8160-2f1f574fff65
Window System : Version 10.0 (Build 19044)
Fault Count: 1
Abnormal termination:
Access violation
Current Thread: ” id 17540
Register State (from fault):
RAX = 3e112e0be826d695 RBX = 0000000000000002
RCX = 00000207c4e87d50 RDX = 000000a5b8fff0f0
RSP = 000000a5b8fff0a8 RBP = 000000000000002a
RSI = 00007ffe3b362a58 RDI = 00007ffe3b345d78
R8 = 0000020724ce0110 R9 = 0000000000004000
R10 = 0000000000000000 R11 = 0000000000000246
R12 = 0000000000000001 R13 = 00007ffe3be3e2f0
R14 = 00007ffe3b3ef180 R15 = 000000000000002a
RIP = 00007ffe3be32166 EFL = 00010202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffe3be32166 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00008550
[ 1] 0x00007ffe3adfa844 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00501828 pspMatlabEng_eng::operator=+00022116
[ 2] 0x00007ffe3ae31c6a E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00728170 PSpiceNewDevEqDLL+00138858
[ 3] 0x00007ffe3ad8f101 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00061697 InitializeDevice+00043665
[ 4] 0x00007ffe3af7dc72 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+02088050 setHInstanceExt+00095330
[ 5] 0x00007ffe3adf3171 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471409 descSetMinTerminalCount+00108705
[ 6] 0x00007ffe3adf30d9 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471257 descSetMinTerminalCount+00108553
[ 7] 0x00007ffe3af592ad E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+01938093 PSpiceDoSimulinkAnalysis+00000925
[ 8] 0x00007ffe3be3155a E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00005466
[ 9] 0x00007ffe3be32584 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00009604
[ 10] 0x00007ffe3be73fef E:binwin64MSVCR110.dll+00147439 beginthreadex+00000263
[ 11] 0x00007ffe3be74196 E:binwin64MSVCR110.dll+00147862 endthreadex+00000402
[ 12] 0x00007fff2b4d7034 C:WindowsSystem32KERNEL32.DLL+00094260 BaseThreadInitThunk+00000020
[ 13] 0x00007fff2bf026a1 C:WindowsSYSTEM32ntdll.dll+00337569 RtlUserThreadStart+00000033
Program State:
Most Recent Simulink Activity:
playSimulationAction : OK in editor 1 at Fri Aug 23 11:03:58 2024Can someone help me with this problem?
After I configured the co-simulation environment, I clicked the run button in simulink, and finally the matlab crash task box popped up. The crash log file is as follows:
——————————————————————————–
Access violation detected at 2024-08-23 11:04:18 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA GeForce RTX 2060 Version 27.21.14.6109 (2020-12-31)
Graphics card 2 : Advanced Micro Devices, Inc. ( 0x1002 ) AMD Radeon(TM) Graphics Version 31.0.14046.0 (2023-3-29)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 6257193
MATLAB Root : E:
MATLAB Version : 9.13.0.2049777 (R2022b)
OpenGL : hardware
Operating System : Microsoft Windows 10 专业版
Process ID : 4572
Processor ID : x86 Family 23 Model 96 Stepping 1, AuthenticAMD
Session Key : 48ca539b-11d4-4b26-8160-2f1f574fff65
Window System : Version 10.0 (Build 19044)
Fault Count: 1
Abnormal termination:
Access violation
Current Thread: ” id 17540
Register State (from fault):
RAX = 3e112e0be826d695 RBX = 0000000000000002
RCX = 00000207c4e87d50 RDX = 000000a5b8fff0f0
RSP = 000000a5b8fff0a8 RBP = 000000000000002a
RSI = 00007ffe3b362a58 RDI = 00007ffe3b345d78
R8 = 0000020724ce0110 R9 = 0000000000004000
R10 = 0000000000000000 R11 = 0000000000000246
R12 = 0000000000000001 R13 = 00007ffe3be3e2f0
R14 = 00007ffe3b3ef180 R15 = 000000000000002a
RIP = 00007ffe3be32166 EFL = 00010202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffe3be32166 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00008550
[ 1] 0x00007ffe3adfa844 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00501828 pspMatlabEng_eng::operator=+00022116
[ 2] 0x00007ffe3ae31c6a E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00728170 PSpiceNewDevEqDLL+00138858
[ 3] 0x00007ffe3ad8f101 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00061697 InitializeDevice+00043665
[ 4] 0x00007ffe3af7dc72 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+02088050 setHInstanceExt+00095330
[ 5] 0x00007ffe3adf3171 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471409 descSetMinTerminalCount+00108705
[ 6] 0x00007ffe3adf30d9 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471257 descSetMinTerminalCount+00108553
[ 7] 0x00007ffe3af592ad E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+01938093 PSpiceDoSimulinkAnalysis+00000925
[ 8] 0x00007ffe3be3155a E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00005466
[ 9] 0x00007ffe3be32584 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00009604
[ 10] 0x00007ffe3be73fef E:binwin64MSVCR110.dll+00147439 beginthreadex+00000263
[ 11] 0x00007ffe3be74196 E:binwin64MSVCR110.dll+00147862 endthreadex+00000402
[ 12] 0x00007fff2b4d7034 C:WindowsSystem32KERNEL32.DLL+00094260 BaseThreadInitThunk+00000020
[ 13] 0x00007fff2bf026a1 C:WindowsSYSTEM32ntdll.dll+00337569 RtlUserThreadStart+00000033
Program State:
Most Recent Simulink Activity:
playSimulationAction : OK in editor 1 at Fri Aug 23 11:03:58 2024 Can someone help me with this problem?
After I configured the co-simulation environment, I clicked the run button in simulink, and finally the matlab crash task box popped up. The crash log file is as follows:
——————————————————————————–
Access violation detected at 2024-08-23 11:04:18 +0800
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA GeForce RTX 2060 Version 27.21.14.6109 (2020-12-31)
Graphics card 2 : Advanced Micro Devices, Inc. ( 0x1002 ) AMD Radeon(TM) Graphics Version 31.0.14046.0 (2023-3-29)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 6257193
MATLAB Root : E:
MATLAB Version : 9.13.0.2049777 (R2022b)
OpenGL : hardware
Operating System : Microsoft Windows 10 专业版
Process ID : 4572
Processor ID : x86 Family 23 Model 96 Stepping 1, AuthenticAMD
Session Key : 48ca539b-11d4-4b26-8160-2f1f574fff65
Window System : Version 10.0 (Build 19044)
Fault Count: 1
Abnormal termination:
Access violation
Current Thread: ” id 17540
Register State (from fault):
RAX = 3e112e0be826d695 RBX = 0000000000000002
RCX = 00000207c4e87d50 RDX = 000000a5b8fff0f0
RSP = 000000a5b8fff0a8 RBP = 000000000000002a
RSI = 00007ffe3b362a58 RDI = 00007ffe3b345d78
R8 = 0000020724ce0110 R9 = 0000000000004000
R10 = 0000000000000000 R11 = 0000000000000246
R12 = 0000000000000001 R13 = 00007ffe3be3e2f0
R14 = 00007ffe3b3ef180 R15 = 000000000000002a
RIP = 00007ffe3be32166 EFL = 00010202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffe3be32166 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00008550
[ 1] 0x00007ffe3adfa844 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00501828 pspMatlabEng_eng::operator=+00022116
[ 2] 0x00007ffe3ae31c6a E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00728170 PSpiceNewDevEqDLL+00138858
[ 3] 0x00007ffe3ad8f101 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00061697 InitializeDevice+00043665
[ 4] 0x00007ffe3af7dc72 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+02088050 setHInstanceExt+00095330
[ 5] 0x00007ffe3adf3171 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471409 descSetMinTerminalCount+00108705
[ 6] 0x00007ffe3adf30d9 E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+00471257 descSetMinTerminalCount+00108553
[ 7] 0x00007ffe3af592ad E:CadenceSPB_17.2toolsbinorPSP_ENG64.dll+01938093 PSpiceDoSimulinkAnalysis+00000925
[ 8] 0x00007ffe3be3155a E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00005466
[ 9] 0x00007ffe3be32584 E:CadenceSPB_17.2toolspspiceslpspsstub.dll+00009604
[ 10] 0x00007ffe3be73fef E:binwin64MSVCR110.dll+00147439 beginthreadex+00000263
[ 11] 0x00007ffe3be74196 E:binwin64MSVCR110.dll+00147862 endthreadex+00000402
[ 12] 0x00007fff2b4d7034 C:WindowsSystem32KERNEL32.DLL+00094260 BaseThreadInitThunk+00000020
[ 13] 0x00007fff2bf026a1 C:WindowsSYSTEM32ntdll.dll+00337569 RtlUserThreadStart+00000033
Program State:
Most Recent Simulink Activity:
playSimulationAction : OK in editor 1 at Fri Aug 23 11:03:58 2024 pspice simulink MATLAB Answers — New Questions
how to change slope of the grid line in logarithmic scale?
x=1:10;
y=exp(.3).*x.^(1); % equation 1
loglog(x,y);
grid on
I want to change the grid line of y axis with slope of equation 1.x=1:10;
y=exp(.3).*x.^(1); % equation 1
loglog(x,y);
grid on
I want to change the grid line of y axis with slope of equation 1. x=1:10;
y=exp(.3).*x.^(1); % equation 1
loglog(x,y);
grid on
I want to change the grid line of y axis with slope of equation 1. grid line, slope, logarithmic MATLAB Answers — New Questions
How to generate a triggered pulse using Simulink
I want to generate a pulse using Simulink when triggered. The output signal is initially 0, then becomes 1 when triggered for a specified time, then -1 for the same amount of time, then back to 0 and hold until triggered again. How can I do this using Simulink.I want to generate a pulse using Simulink when triggered. The output signal is initially 0, then becomes 1 when triggered for a specified time, then -1 for the same amount of time, then back to 0 and hold until triggered again. How can I do this using Simulink. I want to generate a pulse using Simulink when triggered. The output signal is initially 0, then becomes 1 when triggered for a specified time, then -1 for the same amount of time, then back to 0 and hold until triggered again. How can I do this using Simulink. trigger pulse MATLAB Answers — New Questions
figure resize behavior control: from bottom or from top
Hi, I encountered a problem when I resized a figure: The aim of resizing is to manually drag the top/bottom boundary to adjust the panel size, in order to hide the label and only show the buttons. However, the reality is that no matter where I drag, it is the top space hidden, but the space between the label and bottom remains constant. I can only hide the buttons or hide the buttons and label together, but I cannot find a way to resize to keep the bottom. Is there a way to reverse the direction of resizing?
fig = figure(‘Name’,’GUI with Buttons and Labels’,’NumberTitle’,’off’,’Position’,[100 100 400 300]);
% Create buttons
btn1 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 1′,’Position’,[50 200 100 30]);
btn2 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 2′,’Position’,[150 200 100 30]);
btn3 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 3′,’Position’,[250 200 100 30]);
% Create labels
lbl1 = uicontrol(fig,’Style’,’text’,’String’,’Label 1′,’Position’,[50 150 100 30]);
lbl2 = uicontrol(fig,’Style’,’text’,’String’,’Label 2′,’Position’,[150 150 100 30]);
lbl3 = uicontrol(fig,’Style’,’text’,’String’,’Label 3′,’Position’,[250 150 100 30]);Hi, I encountered a problem when I resized a figure: The aim of resizing is to manually drag the top/bottom boundary to adjust the panel size, in order to hide the label and only show the buttons. However, the reality is that no matter where I drag, it is the top space hidden, but the space between the label and bottom remains constant. I can only hide the buttons or hide the buttons and label together, but I cannot find a way to resize to keep the bottom. Is there a way to reverse the direction of resizing?
fig = figure(‘Name’,’GUI with Buttons and Labels’,’NumberTitle’,’off’,’Position’,[100 100 400 300]);
% Create buttons
btn1 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 1′,’Position’,[50 200 100 30]);
btn2 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 2′,’Position’,[150 200 100 30]);
btn3 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 3′,’Position’,[250 200 100 30]);
% Create labels
lbl1 = uicontrol(fig,’Style’,’text’,’String’,’Label 1′,’Position’,[50 150 100 30]);
lbl2 = uicontrol(fig,’Style’,’text’,’String’,’Label 2′,’Position’,[150 150 100 30]);
lbl3 = uicontrol(fig,’Style’,’text’,’String’,’Label 3′,’Position’,[250 150 100 30]); Hi, I encountered a problem when I resized a figure: The aim of resizing is to manually drag the top/bottom boundary to adjust the panel size, in order to hide the label and only show the buttons. However, the reality is that no matter where I drag, it is the top space hidden, but the space between the label and bottom remains constant. I can only hide the buttons or hide the buttons and label together, but I cannot find a way to resize to keep the bottom. Is there a way to reverse the direction of resizing?
fig = figure(‘Name’,’GUI with Buttons and Labels’,’NumberTitle’,’off’,’Position’,[100 100 400 300]);
% Create buttons
btn1 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 1′,’Position’,[50 200 100 30]);
btn2 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 2′,’Position’,[150 200 100 30]);
btn3 = uicontrol(fig,’Style’,’pushbutton’,’String’,’Button 3′,’Position’,[250 200 100 30]);
% Create labels
lbl1 = uicontrol(fig,’Style’,’text’,’String’,’Label 1′,’Position’,[50 150 100 30]);
lbl2 = uicontrol(fig,’Style’,’text’,’String’,’Label 2′,’Position’,[150 150 100 30]);
lbl3 = uicontrol(fig,’Style’,’text’,’String’,’Label 3′,’Position’,[250 150 100 30]); figure, resize MATLAB Answers — New Questions
Extracting Nodes in MATLAB
I have generated a RVE. After meshing, i want to extract the nodes of the two opposite edges in MATLAB. I have use the code below, but it is giving blank.
clear;
fileID = fopen(‘new.txt’);
formatSpec = ‘%s’;
N = 8;
% reads file data, using the formatSpec N times
% c_h: cell header
c_h = textscan(fileID,formatSpec,N,’delimiter’,’|’);
% Read coordinates for nodes on the two opposite surfaces
% Save them in a cell array whose first and fourth columns are node #
% rest columns are x,y,z coordinates
% c_cord
c_cord = textscan(fileID,’%d %f %f %f %d %f %f %f’);
fclose(fileID);
%%
% Turn cell array which stored coordinates info. for points on left and
% right side of RVE into a sorted matrix
% Initialize matrix
cordMatrix=[];
for i=1:N
c1_cell=c_cord(1,i);
c1_elem=c1_cell{1,1};
cordMatrix(:,i)=c1_elem;
end
% Sort the matrix by the third column-Y coordinates
% sortedMatrixByLy-sorted matrix by left y coordinates
sortedMatrixByLy=sortrows(cordMatrix, 3);
% sortedMatrixByRy-sorted matrix by right y coordinates
sortedMatrixByRy=sortrows(cordMatrix, 3);
%%
% pairwise distance between left and right side sets of points
% # of points on Left side and right side do NOT have to the the same
Left=sortedMatrixByLy(:,1:4);
Right=sortedMatrixByRy(:,5:8);
% Fetch the x,y,z coordinates of left side points
LC=Left(:,2:4);
% Fetch the x,y,z coordinates of right side points
RC=Right(:,2:4);
% Compute all the distances between points on left and right side
% i.e. left has M points, right has N points, size of D matrix is M*N
D = pdist2(LC,RC);
%%
% Find the minimum distance value in each row of D and
% return the corresponding indices
DD=D;
[Sml,ind] = min(DD,[],2);
for j=1:size(DD,1)
[Sml(j),ind(j)] = min(DD(j,:),[],2);
% Replace the value in the same column of ind(j) by a very large number
% eg.999999 in here to avoid duplicat indice (i.e. the same point on one
% side used more than once)
DD(:,ind(j))=999999;
end
% Based on the returned indices find the paired points on left and right
% sides which has minimum distances
% The paired nodes then can be incorporated into FEA package Abaqus input file to
% define Periodic Boundary Conditions by using "Equations" in Abaqus
% pn:parid nodes
pn=[Left(:,1) Right(ind,1)]I have generated a RVE. After meshing, i want to extract the nodes of the two opposite edges in MATLAB. I have use the code below, but it is giving blank.
clear;
fileID = fopen(‘new.txt’);
formatSpec = ‘%s’;
N = 8;
% reads file data, using the formatSpec N times
% c_h: cell header
c_h = textscan(fileID,formatSpec,N,’delimiter’,’|’);
% Read coordinates for nodes on the two opposite surfaces
% Save them in a cell array whose first and fourth columns are node #
% rest columns are x,y,z coordinates
% c_cord
c_cord = textscan(fileID,’%d %f %f %f %d %f %f %f’);
fclose(fileID);
%%
% Turn cell array which stored coordinates info. for points on left and
% right side of RVE into a sorted matrix
% Initialize matrix
cordMatrix=[];
for i=1:N
c1_cell=c_cord(1,i);
c1_elem=c1_cell{1,1};
cordMatrix(:,i)=c1_elem;
end
% Sort the matrix by the third column-Y coordinates
% sortedMatrixByLy-sorted matrix by left y coordinates
sortedMatrixByLy=sortrows(cordMatrix, 3);
% sortedMatrixByRy-sorted matrix by right y coordinates
sortedMatrixByRy=sortrows(cordMatrix, 3);
%%
% pairwise distance between left and right side sets of points
% # of points on Left side and right side do NOT have to the the same
Left=sortedMatrixByLy(:,1:4);
Right=sortedMatrixByRy(:,5:8);
% Fetch the x,y,z coordinates of left side points
LC=Left(:,2:4);
% Fetch the x,y,z coordinates of right side points
RC=Right(:,2:4);
% Compute all the distances between points on left and right side
% i.e. left has M points, right has N points, size of D matrix is M*N
D = pdist2(LC,RC);
%%
% Find the minimum distance value in each row of D and
% return the corresponding indices
DD=D;
[Sml,ind] = min(DD,[],2);
for j=1:size(DD,1)
[Sml(j),ind(j)] = min(DD(j,:),[],2);
% Replace the value in the same column of ind(j) by a very large number
% eg.999999 in here to avoid duplicat indice (i.e. the same point on one
% side used more than once)
DD(:,ind(j))=999999;
end
% Based on the returned indices find the paired points on left and right
% sides which has minimum distances
% The paired nodes then can be incorporated into FEA package Abaqus input file to
% define Periodic Boundary Conditions by using "Equations" in Abaqus
% pn:parid nodes
pn=[Left(:,1) Right(ind,1)] I have generated a RVE. After meshing, i want to extract the nodes of the two opposite edges in MATLAB. I have use the code below, but it is giving blank.
clear;
fileID = fopen(‘new.txt’);
formatSpec = ‘%s’;
N = 8;
% reads file data, using the formatSpec N times
% c_h: cell header
c_h = textscan(fileID,formatSpec,N,’delimiter’,’|’);
% Read coordinates for nodes on the two opposite surfaces
% Save them in a cell array whose first and fourth columns are node #
% rest columns are x,y,z coordinates
% c_cord
c_cord = textscan(fileID,’%d %f %f %f %d %f %f %f’);
fclose(fileID);
%%
% Turn cell array which stored coordinates info. for points on left and
% right side of RVE into a sorted matrix
% Initialize matrix
cordMatrix=[];
for i=1:N
c1_cell=c_cord(1,i);
c1_elem=c1_cell{1,1};
cordMatrix(:,i)=c1_elem;
end
% Sort the matrix by the third column-Y coordinates
% sortedMatrixByLy-sorted matrix by left y coordinates
sortedMatrixByLy=sortrows(cordMatrix, 3);
% sortedMatrixByRy-sorted matrix by right y coordinates
sortedMatrixByRy=sortrows(cordMatrix, 3);
%%
% pairwise distance between left and right side sets of points
% # of points on Left side and right side do NOT have to the the same
Left=sortedMatrixByLy(:,1:4);
Right=sortedMatrixByRy(:,5:8);
% Fetch the x,y,z coordinates of left side points
LC=Left(:,2:4);
% Fetch the x,y,z coordinates of right side points
RC=Right(:,2:4);
% Compute all the distances between points on left and right side
% i.e. left has M points, right has N points, size of D matrix is M*N
D = pdist2(LC,RC);
%%
% Find the minimum distance value in each row of D and
% return the corresponding indices
DD=D;
[Sml,ind] = min(DD,[],2);
for j=1:size(DD,1)
[Sml(j),ind(j)] = min(DD(j,:),[],2);
% Replace the value in the same column of ind(j) by a very large number
% eg.999999 in here to avoid duplicat indice (i.e. the same point on one
% side used more than once)
DD(:,ind(j))=999999;
end
% Based on the returned indices find the paired points on left and right
% sides which has minimum distances
% The paired nodes then can be incorporated into FEA package Abaqus input file to
% define Periodic Boundary Conditions by using "Equations" in Abaqus
% pn:parid nodes
pn=[Left(:,1) Right(ind,1)] nodes, rve MATLAB Answers — New Questions
I put a breaker model in my circuit. And i found that it closes when the current is zero and the external signal is 0.
The circuit is a systhetic circuit usually used for circuit breaker. I add a half sine current on the breaker, and then put a very high voltage Oscillating voltage on it. The half sine current (20kA) meets zero at the 0.01s, and the extern signal for breaker is 0.009s, which means that it will open at the 0.01s. And it actually did. The Oscillating volatge source is added at 0.011s. However, when I reduce the half sine current to about 5kA, something magical happened. The breaker closes again and there is another current that flows through the breaker. And this problem still existed even when I changed the time stamp to put a very high voltage Oscillating voltage to 0.015s as I thought it needed enough time to open the breaker.
I really want to know why this happens and how to solve the problem that the breaker doesn’t opens as i think.
Here is the current that flows through breaker.
Here is my breaker configurations.The circuit is a systhetic circuit usually used for circuit breaker. I add a half sine current on the breaker, and then put a very high voltage Oscillating voltage on it. The half sine current (20kA) meets zero at the 0.01s, and the extern signal for breaker is 0.009s, which means that it will open at the 0.01s. And it actually did. The Oscillating volatge source is added at 0.011s. However, when I reduce the half sine current to about 5kA, something magical happened. The breaker closes again and there is another current that flows through the breaker. And this problem still existed even when I changed the time stamp to put a very high voltage Oscillating voltage to 0.015s as I thought it needed enough time to open the breaker.
I really want to know why this happens and how to solve the problem that the breaker doesn’t opens as i think.
Here is the current that flows through breaker.
Here is my breaker configurations. The circuit is a systhetic circuit usually used for circuit breaker. I add a half sine current on the breaker, and then put a very high voltage Oscillating voltage on it. The half sine current (20kA) meets zero at the 0.01s, and the extern signal for breaker is 0.009s, which means that it will open at the 0.01s. And it actually did. The Oscillating volatge source is added at 0.011s. However, when I reduce the half sine current to about 5kA, something magical happened. The breaker closes again and there is another current that flows through the breaker. And this problem still existed even when I changed the time stamp to put a very high voltage Oscillating voltage to 0.015s as I thought it needed enough time to open the breaker.
I really want to know why this happens and how to solve the problem that the breaker doesn’t opens as i think.
Here is the current that flows through breaker.
Here is my breaker configurations. breaker MATLAB Answers — New Questions
How to get shapley value for Neural Network trained on matlab? it keeps error…
Hi there,
I wanted to get shapley value of my pre-trained ANN.
it is regression model.
it’s input’s shape is 7*5120 double
and output is 1*5120 double.
I’m confused with idea of shapley.. sorryHi there,
I wanted to get shapley value of my pre-trained ANN.
it is regression model.
it’s input’s shape is 7*5120 double
and output is 1*5120 double.
I’m confused with idea of shapley.. sorry Hi there,
I wanted to get shapley value of my pre-trained ANN.
it is regression model.
it’s input’s shape is 7*5120 double
and output is 1*5120 double.
I’m confused with idea of shapley.. sorry shapley value, neural network MATLAB Answers — New Questions
How to normalise segregated surface emg signals into the same number of data points?
Hi everyone,
I have a cell array containing multiple gait cycles of an SEMG signal. Each cycle represents the push phase and recovery phase of a wheelchair. I want to get the average of the SEMG signal of all the cycles however, each cycle contains a different amount of data points. How do I normalise the cycles to contain a certain amount of data points without disrupting the signals? I also have a cell array containg the times of propulsion.
If anyone could point me in the right direction that would be great!
Thanks,Hi everyone,
I have a cell array containing multiple gait cycles of an SEMG signal. Each cycle represents the push phase and recovery phase of a wheelchair. I want to get the average of the SEMG signal of all the cycles however, each cycle contains a different amount of data points. How do I normalise the cycles to contain a certain amount of data points without disrupting the signals? I also have a cell array containg the times of propulsion.
If anyone could point me in the right direction that would be great!
Thanks, Hi everyone,
I have a cell array containing multiple gait cycles of an SEMG signal. Each cycle represents the push phase and recovery phase of a wheelchair. I want to get the average of the SEMG signal of all the cycles however, each cycle contains a different amount of data points. How do I normalise the cycles to contain a certain amount of data points without disrupting the signals? I also have a cell array containg the times of propulsion.
If anyone could point me in the right direction that would be great!
Thanks, signal processing, semg MATLAB Answers — New Questions
Plotting random number in a line
Hi Matlab Team,
I have X = rand(1,100), and I want to plot X such that points be in X axis. At the moment, when I use plot(X, ‘*’), we have index 1 to 100 on x-axis and X is in the vertical axis. This is not, what I want !!!
ThanksHi Matlab Team,
I have X = rand(1,100), and I want to plot X such that points be in X axis. At the moment, when I use plot(X, ‘*’), we have index 1 to 100 on x-axis and X is in the vertical axis. This is not, what I want !!!
Thanks Hi Matlab Team,
I have X = rand(1,100), and I want to plot X such that points be in X axis. At the moment, when I use plot(X, ‘*’), we have index 1 to 100 on x-axis and X is in the vertical axis. This is not, what I want !!!
Thanks plot, random number MATLAB Answers — New Questions
the question is on linear programming problems
A farm manufacturers three products P1, P2 and P3 using two machines M1 and M2. The product yield a contribution of sh.3 sh.2 and sh.4 respectively. Machine M1 and M2 have 2000 and 2500 machine hours respectively. There is an agreement with trading association to manufacture at least 100 units of P1, 200 units of P2 and 50 units of P3 but not more than 150 units of P1. The table below shows the processing time in hours for each machine on each product.
products
machines P1 P2 P3
M1 4 3 5
M2 2 2 4
required:
i. The production plan that maximizes contributionA farm manufacturers three products P1, P2 and P3 using two machines M1 and M2. The product yield a contribution of sh.3 sh.2 and sh.4 respectively. Machine M1 and M2 have 2000 and 2500 machine hours respectively. There is an agreement with trading association to manufacture at least 100 units of P1, 200 units of P2 and 50 units of P3 but not more than 150 units of P1. The table below shows the processing time in hours for each machine on each product.
products
machines P1 P2 P3
M1 4 3 5
M2 2 2 4
required:
i. The production plan that maximizes contribution A farm manufacturers three products P1, P2 and P3 using two machines M1 and M2. The product yield a contribution of sh.3 sh.2 and sh.4 respectively. Machine M1 and M2 have 2000 and 2500 machine hours respectively. There is an agreement with trading association to manufacture at least 100 units of P1, 200 units of P2 and 50 units of P3 but not more than 150 units of P1. The table below shows the processing time in hours for each machine on each product.
products
machines P1 P2 P3
M1 4 3 5
M2 2 2 4
required:
i. The production plan that maximizes contribution #operarions research MATLAB Answers — New Questions
Measuring average intensity of pixels for multiple images.
I am trying to read multiple similar images located in a folder and find the average intensity of pixels of the images. Following is the code I wrote initially which works fine:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
for k = 1:B_0
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
end
B1 = cat(3,I{:});
black = mean(B1,3);
However, upon getting suggested to use vectorization to make the process faster, I wrote the following code:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
k = 1:B_0;
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
B1 = cat(3,I{:});
black = mean(B1,3);
I am getting the following error:
Error using dir
Pathname ‘D:dummy locationBLACK1.tif10.tif100.tif101.tif102.tif103.tif104.tif105.tif106.tif107.tif108.tif109.tif11.tif110.tif111.tif112.tif113.tif114.tif115.tif116.tif117.tif118.tif119.tif12.tif120.tif121.tif122.tif123.tif124.tif125.tif126.tif127.tif128.tif129.tif13.tif130.tif131.tif132.tif133.tif134.tif135.tif136.tif137.tif138.tif139.tif14.tif140.tif141.tif142.tif143.tif144.tif145.tif146.tif147.tif148.tif149.tif15.tif150.tif151.tif152.tif153.tif154.tif155.tif156.tif157.tif158.tif159.tif16.tif160.tif161.tif162.tif163.tif164.tif165.tif166.tif167.tif168.tif169.tif17.tif170.tif171.tif172.tif173.tif174.tif175.tif176.tif177.tif178.tif179.tif18.tif180.tif181.tif182.tif183.tif184.tif185.tif186.tif187.tif188.tif189.tif19.tif190.tif191.tif192.tif193.tif194.tif195.tif196.tif197.tif198.tif199.tif2.tif20.tif200.tif201.tif202.tif203.tif204.tif205.tif206.tif207.tif208.tif209.tif21.tif210.tif211.tif212.tif213.tif214.tif215.tif216.tif217.tif218.tif219.tif22.tif220.tif221.tif222.tif223.tif224.tif225.tif226.tif227.tif228.tif229.tif23.tif230.tif231.tif232.tif233.tif234.tif235.tif236.tif237.tif238.tif239.tif24.tif240.tif241.tif242.tif243.tif244.tif245.tif246.tif247.tif248.tif249.tif25.tif250.tif251.tif252.tif253.tif254.tif255.tif256.tif257.tif258.tif259.tif26.tif260.tif261.tif262.tif263.tif264.tif265.tif266.tif267.tif268.tif269.tif27.tif270.tif271.tif272.tif273.tif274.tif275.tif276.tif277.tif278.tif279.tif28.tif280.tif281.tif282.tif283.tif284.tif285.tif286.tif287.tif288.tif289.tif29.tif290.tif291.tif292.tif293.tif294.tif295.tif296.tif297.tif298.tif299.tif3.tif30.tif300.tif301.tif302.tif303.tif304.tif305.tif306.tif307.tif308.tif309.tif31.tif310.tif311.tif312.tif313.tif314.tif315.tif316.tif317.tif318.tif319.tif32.tif320.tif321.tif322.tif323.tif324.tif325.tif326.tif327.tif328.tif329.tif33.tif330.tif331.tif332.tif333.tif334.tif335.tif336.tif337.tif338.tif339.tif34.tif340.tif341.tif342.tif343.tif344.tif345.tif346.tif347.tif348.tif349.tif35.tif350.tif351.tif352.tif353.tif354.tif355.tif356.tif357.tif358.tif359.tif36.tif360.tif361.tif362.tif363.tif364.tif365.tif366.tif367.tif368.tif369.tif37.tif370.tif371.tif372.tif373.tif374.tif375.tif376.tif377.tif378.tif379.tif38.tif380.tif381.tif382.tif383.tif384.tif385.tif386.tif387.tif388.tif389.tif39.tif390.tif391.tif392.tif393.tif394.tif395.tif396.tif397.tif398.tif399.tif4.tif40.tif400.tif401.tif402.tif403.tif404.tif405.tif406.tif407.tif408.tif409.tif41.tif410.tif411.tif412.tif413.tif414.tif415.tif416.tif417.tif418.tif419.tif42.tif420.tif421.tif422.tif423.tif424.tif425.tif426.tif427.tif428.tif429.tif43.tif430.tif431.tif432.tif433.tif434.tif435.tif436.tif437.tif438.tif439.tif44.tif440.tif441.tif442.tif443.tif444.tif445.tif446.tif447.tif448.tif449.tif45.tif450.tif451.tif452.tif453.tif454.tif455.tif456.tif457.tif458.tif459.tif46.tif460.tif461.tif462.tif463.tif464.tif465.tif466.tif467.tif468.tif469.tif47.tif470.tif471.tif472.tif473.tif474.tif475.tif476.tif477.tif478.tif479.tif48.tif480.tif481.tif482.tif483.tif484.tif485.tif486.tif487.tif488.tif489.tif49.tif490.tif491.tif492.tif493.tif494.tif495.tif496.tif497.tif498.tif499.tif5.tif50.tif500.tif51.tif52.tif53.tif54.tif55.tif56.tif57.tif58.tif59.tif6.tif60.tif61.tif62.tif63.tif64.tif65.tif66.tif67.tif68.tif69.tif7.tif70.tif71.tif72.tif73.tif74.tif75.tif76.tif77.tif78.tif79.tif8.tif80.tif81.tif82.tif83.tif84.tif85.tif86.tif87.tif88.tif89.tif9.tif90.tif91.tif92.tif93.tif94.tif95.tif96.tif97.tif98.tif99.tif’
is too long.
Error in imread>get_full_filename (line 560)
if ~isempty(dir(filename))
Error in imread (line 371)
fullname = get_full_filename(filename);
Error in avg_new (line 12)
I{k} = imread(F);
Can anyone please help me correcting this error to get the same result as my first code?I am trying to read multiple similar images located in a folder and find the average intensity of pixels of the images. Following is the code I wrote initially which works fine:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
for k = 1:B_0
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
end
B1 = cat(3,I{:});
black = mean(B1,3);
However, upon getting suggested to use vectorization to make the process faster, I wrote the following code:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
k = 1:B_0;
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
B1 = cat(3,I{:});
black = mean(B1,3);
I am getting the following error:
Error using dir
Pathname ‘D:dummy locationBLACK1.tif10.tif100.tif101.tif102.tif103.tif104.tif105.tif106.tif107.tif108.tif109.tif11.tif110.tif111.tif112.tif113.tif114.tif115.tif116.tif117.tif118.tif119.tif12.tif120.tif121.tif122.tif123.tif124.tif125.tif126.tif127.tif128.tif129.tif13.tif130.tif131.tif132.tif133.tif134.tif135.tif136.tif137.tif138.tif139.tif14.tif140.tif141.tif142.tif143.tif144.tif145.tif146.tif147.tif148.tif149.tif15.tif150.tif151.tif152.tif153.tif154.tif155.tif156.tif157.tif158.tif159.tif16.tif160.tif161.tif162.tif163.tif164.tif165.tif166.tif167.tif168.tif169.tif17.tif170.tif171.tif172.tif173.tif174.tif175.tif176.tif177.tif178.tif179.tif18.tif180.tif181.tif182.tif183.tif184.tif185.tif186.tif187.tif188.tif189.tif19.tif190.tif191.tif192.tif193.tif194.tif195.tif196.tif197.tif198.tif199.tif2.tif20.tif200.tif201.tif202.tif203.tif204.tif205.tif206.tif207.tif208.tif209.tif21.tif210.tif211.tif212.tif213.tif214.tif215.tif216.tif217.tif218.tif219.tif22.tif220.tif221.tif222.tif223.tif224.tif225.tif226.tif227.tif228.tif229.tif23.tif230.tif231.tif232.tif233.tif234.tif235.tif236.tif237.tif238.tif239.tif24.tif240.tif241.tif242.tif243.tif244.tif245.tif246.tif247.tif248.tif249.tif25.tif250.tif251.tif252.tif253.tif254.tif255.tif256.tif257.tif258.tif259.tif26.tif260.tif261.tif262.tif263.tif264.tif265.tif266.tif267.tif268.tif269.tif27.tif270.tif271.tif272.tif273.tif274.tif275.tif276.tif277.tif278.tif279.tif28.tif280.tif281.tif282.tif283.tif284.tif285.tif286.tif287.tif288.tif289.tif29.tif290.tif291.tif292.tif293.tif294.tif295.tif296.tif297.tif298.tif299.tif3.tif30.tif300.tif301.tif302.tif303.tif304.tif305.tif306.tif307.tif308.tif309.tif31.tif310.tif311.tif312.tif313.tif314.tif315.tif316.tif317.tif318.tif319.tif32.tif320.tif321.tif322.tif323.tif324.tif325.tif326.tif327.tif328.tif329.tif33.tif330.tif331.tif332.tif333.tif334.tif335.tif336.tif337.tif338.tif339.tif34.tif340.tif341.tif342.tif343.tif344.tif345.tif346.tif347.tif348.tif349.tif35.tif350.tif351.tif352.tif353.tif354.tif355.tif356.tif357.tif358.tif359.tif36.tif360.tif361.tif362.tif363.tif364.tif365.tif366.tif367.tif368.tif369.tif37.tif370.tif371.tif372.tif373.tif374.tif375.tif376.tif377.tif378.tif379.tif38.tif380.tif381.tif382.tif383.tif384.tif385.tif386.tif387.tif388.tif389.tif39.tif390.tif391.tif392.tif393.tif394.tif395.tif396.tif397.tif398.tif399.tif4.tif40.tif400.tif401.tif402.tif403.tif404.tif405.tif406.tif407.tif408.tif409.tif41.tif410.tif411.tif412.tif413.tif414.tif415.tif416.tif417.tif418.tif419.tif42.tif420.tif421.tif422.tif423.tif424.tif425.tif426.tif427.tif428.tif429.tif43.tif430.tif431.tif432.tif433.tif434.tif435.tif436.tif437.tif438.tif439.tif44.tif440.tif441.tif442.tif443.tif444.tif445.tif446.tif447.tif448.tif449.tif45.tif450.tif451.tif452.tif453.tif454.tif455.tif456.tif457.tif458.tif459.tif46.tif460.tif461.tif462.tif463.tif464.tif465.tif466.tif467.tif468.tif469.tif47.tif470.tif471.tif472.tif473.tif474.tif475.tif476.tif477.tif478.tif479.tif48.tif480.tif481.tif482.tif483.tif484.tif485.tif486.tif487.tif488.tif489.tif49.tif490.tif491.tif492.tif493.tif494.tif495.tif496.tif497.tif498.tif499.tif5.tif50.tif500.tif51.tif52.tif53.tif54.tif55.tif56.tif57.tif58.tif59.tif6.tif60.tif61.tif62.tif63.tif64.tif65.tif66.tif67.tif68.tif69.tif7.tif70.tif71.tif72.tif73.tif74.tif75.tif76.tif77.tif78.tif79.tif8.tif80.tif81.tif82.tif83.tif84.tif85.tif86.tif87.tif88.tif89.tif9.tif90.tif91.tif92.tif93.tif94.tif95.tif96.tif97.tif98.tif99.tif’
is too long.
Error in imread>get_full_filename (line 560)
if ~isempty(dir(filename))
Error in imread (line 371)
fullname = get_full_filename(filename);
Error in avg_new (line 12)
I{k} = imread(F);
Can anyone please help me correcting this error to get the same result as my first code? I am trying to read multiple similar images located in a folder and find the average intensity of pixels of the images. Following is the code I wrote initially which works fine:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
for k = 1:B_0
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
end
B1 = cat(3,I{:});
black = mean(B1,3);
However, upon getting suggested to use vectorization to make the process faster, I wrote the following code:
Location = ‘D:\dummy location’;
B = dir(fullfile(sprintf(Location),sprintf(‘BLACK’), ‘*.tif’));
B_0 = numel(B);
k = 1:B_0;
F = fullfile(sprintf(Location),sprintf(‘BLACK’),B(k).name);
I{k} = imread(F);
B1 = cat(3,I{:});
black = mean(B1,3);
I am getting the following error:
Error using dir
Pathname ‘D:dummy locationBLACK1.tif10.tif100.tif101.tif102.tif103.tif104.tif105.tif106.tif107.tif108.tif109.tif11.tif110.tif111.tif112.tif113.tif114.tif115.tif116.tif117.tif118.tif119.tif12.tif120.tif121.tif122.tif123.tif124.tif125.tif126.tif127.tif128.tif129.tif13.tif130.tif131.tif132.tif133.tif134.tif135.tif136.tif137.tif138.tif139.tif14.tif140.tif141.tif142.tif143.tif144.tif145.tif146.tif147.tif148.tif149.tif15.tif150.tif151.tif152.tif153.tif154.tif155.tif156.tif157.tif158.tif159.tif16.tif160.tif161.tif162.tif163.tif164.tif165.tif166.tif167.tif168.tif169.tif17.tif170.tif171.tif172.tif173.tif174.tif175.tif176.tif177.tif178.tif179.tif18.tif180.tif181.tif182.tif183.tif184.tif185.tif186.tif187.tif188.tif189.tif19.tif190.tif191.tif192.tif193.tif194.tif195.tif196.tif197.tif198.tif199.tif2.tif20.tif200.tif201.tif202.tif203.tif204.tif205.tif206.tif207.tif208.tif209.tif21.tif210.tif211.tif212.tif213.tif214.tif215.tif216.tif217.tif218.tif219.tif22.tif220.tif221.tif222.tif223.tif224.tif225.tif226.tif227.tif228.tif229.tif23.tif230.tif231.tif232.tif233.tif234.tif235.tif236.tif237.tif238.tif239.tif24.tif240.tif241.tif242.tif243.tif244.tif245.tif246.tif247.tif248.tif249.tif25.tif250.tif251.tif252.tif253.tif254.tif255.tif256.tif257.tif258.tif259.tif26.tif260.tif261.tif262.tif263.tif264.tif265.tif266.tif267.tif268.tif269.tif27.tif270.tif271.tif272.tif273.tif274.tif275.tif276.tif277.tif278.tif279.tif28.tif280.tif281.tif282.tif283.tif284.tif285.tif286.tif287.tif288.tif289.tif29.tif290.tif291.tif292.tif293.tif294.tif295.tif296.tif297.tif298.tif299.tif3.tif30.tif300.tif301.tif302.tif303.tif304.tif305.tif306.tif307.tif308.tif309.tif31.tif310.tif311.tif312.tif313.tif314.tif315.tif316.tif317.tif318.tif319.tif32.tif320.tif321.tif322.tif323.tif324.tif325.tif326.tif327.tif328.tif329.tif33.tif330.tif331.tif332.tif333.tif334.tif335.tif336.tif337.tif338.tif339.tif34.tif340.tif341.tif342.tif343.tif344.tif345.tif346.tif347.tif348.tif349.tif35.tif350.tif351.tif352.tif353.tif354.tif355.tif356.tif357.tif358.tif359.tif36.tif360.tif361.tif362.tif363.tif364.tif365.tif366.tif367.tif368.tif369.tif37.tif370.tif371.tif372.tif373.tif374.tif375.tif376.tif377.tif378.tif379.tif38.tif380.tif381.tif382.tif383.tif384.tif385.tif386.tif387.tif388.tif389.tif39.tif390.tif391.tif392.tif393.tif394.tif395.tif396.tif397.tif398.tif399.tif4.tif40.tif400.tif401.tif402.tif403.tif404.tif405.tif406.tif407.tif408.tif409.tif41.tif410.tif411.tif412.tif413.tif414.tif415.tif416.tif417.tif418.tif419.tif42.tif420.tif421.tif422.tif423.tif424.tif425.tif426.tif427.tif428.tif429.tif43.tif430.tif431.tif432.tif433.tif434.tif435.tif436.tif437.tif438.tif439.tif44.tif440.tif441.tif442.tif443.tif444.tif445.tif446.tif447.tif448.tif449.tif45.tif450.tif451.tif452.tif453.tif454.tif455.tif456.tif457.tif458.tif459.tif46.tif460.tif461.tif462.tif463.tif464.tif465.tif466.tif467.tif468.tif469.tif47.tif470.tif471.tif472.tif473.tif474.tif475.tif476.tif477.tif478.tif479.tif48.tif480.tif481.tif482.tif483.tif484.tif485.tif486.tif487.tif488.tif489.tif49.tif490.tif491.tif492.tif493.tif494.tif495.tif496.tif497.tif498.tif499.tif5.tif50.tif500.tif51.tif52.tif53.tif54.tif55.tif56.tif57.tif58.tif59.tif6.tif60.tif61.tif62.tif63.tif64.tif65.tif66.tif67.tif68.tif69.tif7.tif70.tif71.tif72.tif73.tif74.tif75.tif76.tif77.tif78.tif79.tif8.tif80.tif81.tif82.tif83.tif84.tif85.tif86.tif87.tif88.tif89.tif9.tif90.tif91.tif92.tif93.tif94.tif95.tif96.tif97.tif98.tif99.tif’
is too long.
Error in imread>get_full_filename (line 560)
if ~isempty(dir(filename))
Error in imread (line 371)
fullname = get_full_filename(filename);
Error in avg_new (line 12)
I{k} = imread(F);
Can anyone please help me correcting this error to get the same result as my first code? vectorization, image analysis, image processing MATLAB Answers — New Questions
How to interpret Anomaly Scores for One Class Support Vector Machines
I am using One Class Support Vector Machines for anomaly detection. Here is the anomaly scores histogram (attached) for the model trained with 274 samples and tested with 31 samples. How do I determine the true/false prediction rates from the anomaly scores histogram.
Thank YouI am using One Class Support Vector Machines for anomaly detection. Here is the anomaly scores histogram (attached) for the model trained with 274 samples and tested with 31 samples. How do I determine the true/false prediction rates from the anomaly scores histogram.
Thank You I am using One Class Support Vector Machines for anomaly detection. Here is the anomaly scores histogram (attached) for the model trained with 274 samples and tested with 31 samples. How do I determine the true/false prediction rates from the anomaly scores histogram.
Thank You anomaly, one class svm, scores MATLAB Answers — New Questions