Category: Matlab
Category Archives: Matlab
Error: unable to resolve the name
I have some code which generates a variable name iteratively in a loop, It was working fine but now I get the error: unable to resolve the name ‘pre1min.windowchunkIdx’.
preORpost = {‘pre’ ‘post’}
all_type_ALL = []; %output for all voc types for all ppts
%load raw data
for pOp = 1:length(preORpost)
for min = 1:2
%window = [preORpost{pOp} num2str(min) ‘min’];
varName = [preORpost{pOp} num2str(min) ‘min’]; % Generate variable name
fieldName = ‘windowchunkIdx’; % Generate field name
windowchunk = eval([varName ‘.’ fieldName]);I have some code which generates a variable name iteratively in a loop, It was working fine but now I get the error: unable to resolve the name ‘pre1min.windowchunkIdx’.
preORpost = {‘pre’ ‘post’}
all_type_ALL = []; %output for all voc types for all ppts
%load raw data
for pOp = 1:length(preORpost)
for min = 1:2
%window = [preORpost{pOp} num2str(min) ‘min’];
varName = [preORpost{pOp} num2str(min) ‘min’]; % Generate variable name
fieldName = ‘windowchunkIdx’; % Generate field name
windowchunk = eval([varName ‘.’ fieldName]); I have some code which generates a variable name iteratively in a loop, It was working fine but now I get the error: unable to resolve the name ‘pre1min.windowchunkIdx’.
preORpost = {‘pre’ ‘post’}
all_type_ALL = []; %output for all voc types for all ppts
%load raw data
for pOp = 1:length(preORpost)
for min = 1:2
%window = [preORpost{pOp} num2str(min) ‘min’];
varName = [preORpost{pOp} num2str(min) ‘min’]; % Generate variable name
fieldName = ‘windowchunkIdx’; % Generate field name
windowchunk = eval([varName ‘.’ fieldName]); variable, name, loop MATLAB Answers — New Questions
activate matlab.sh file is missing in the bin folder
while installing matlab according to the documentation,the activate file is missing.while installing matlab according to the documentation,the activate file is missing. while installing matlab according to the documentation,the activate file is missing. matlab, installation MATLAB Answers — New Questions
function-loop-if statment
"Write a function that asks the user to input 10 numbers and calculates the sum of the odd numbers entered (use for loop + if)" I couldn’t figure it out at all as functions cannot be added in loops, so im not sure"Write a function that asks the user to input 10 numbers and calculates the sum of the odd numbers entered (use for loop + if)" I couldn’t figure it out at all as functions cannot be added in loops, so im not sure "Write a function that asks the user to input 10 numbers and calculates the sum of the odd numbers entered (use for loop + if)" I couldn’t figure it out at all as functions cannot be added in loops, so im not sure for loop, if statement, function MATLAB Answers — New Questions
How to use Bluetooth Low Energy in a compiled application ?
I am trying to compile a Matlab Application using BLE communication into a standalone app. The application is compiled properly, without any errors, and can be launched, but each time I try to scan BLE devices using the function blelist, the application crashes.
I used the diary function to get the error message, and it says that " Bluetooth permission is not enabled for MATLAB. Allow MATLAB or Terminal to use Bluetooth from the Security & Privacy settings ". Of course, I allowed both Matlab and Terminal to use Bluetooth, but the errors still occurs and the application continues to crash.
I don’t know if I missed an application to add into the Bluetooth permissions, like an executable of Matlab Runtime ?
I work on macOs, if it can help.
Thanks for your help !I am trying to compile a Matlab Application using BLE communication into a standalone app. The application is compiled properly, without any errors, and can be launched, but each time I try to scan BLE devices using the function blelist, the application crashes.
I used the diary function to get the error message, and it says that " Bluetooth permission is not enabled for MATLAB. Allow MATLAB or Terminal to use Bluetooth from the Security & Privacy settings ". Of course, I allowed both Matlab and Terminal to use Bluetooth, but the errors still occurs and the application continues to crash.
I don’t know if I missed an application to add into the Bluetooth permissions, like an executable of Matlab Runtime ?
I work on macOs, if it can help.
Thanks for your help ! I am trying to compile a Matlab Application using BLE communication into a standalone app. The application is compiled properly, without any errors, and can be launched, but each time I try to scan BLE devices using the function blelist, the application crashes.
I used the diary function to get the error message, and it says that " Bluetooth permission is not enabled for MATLAB. Allow MATLAB or Terminal to use Bluetooth from the Security & Privacy settings ". Of course, I allowed both Matlab and Terminal to use Bluetooth, but the errors still occurs and the application continues to crash.
I don’t know if I missed an application to add into the Bluetooth permissions, like an executable of Matlab Runtime ?
I work on macOs, if it can help.
Thanks for your help ! bluetooth, standalone application, matlab compiler, matlab runtime, blelist MATLAB Answers — New Questions
Overview Error when creating RTU Object in MODBUS EXPLORER
When I want to create an Device via. "Modbus Explorer" it works flawless when I choose Modbus TCP. When I try to do the same with Modbus RTU, I get the following window. Only explenation window about config settings, but no Config setting available. Seems to me like a bug. Is there a fix for it ?
In Matlab I get this codes as feedback:
Warning: Error executing listener callback for PostSet event on UserAddNonEnumDeviceStartPage dynamic property in object of matlabshared.mediator.internal.Mediator class:
Error using matlab.ui.internal.toolstrip.DropDown/set.SelectedIndex
"SelectedIndex" property accepts an integer between 1 and the number of items.
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createDropDown (line 534)
valueWidget.SelectedIndex = 1;
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createWidget (line 436)
valueWidget = createDropDown(paramStruct.ParamID);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab (line 337)
valueWidget = createWidget(paramStruct);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler (line 118)
obj.populateTab();
Error in matlab.hwmgr.internal.Toolstrip/showModalTsTab (line 518)
obj.ModalTabHandler = matlab.hwmgr.internal.toolstrip.ParamTabHandler(…
Error in matlab.hwmgr.internal.Toolstrip/showNonEnumDeviceConfigTab (line 363)
obj.showModalTsTab(descriptor, @obj.confirmAddDevice, @()obj.cancelConfiguringDevice(cancelDestination));
Error in matlab.hwmgr.internal.Toolstrip/startNonEnumDeviceConfig (line 394)
obj.showNonEnumDeviceConfigTab(descriptor, cancelDestination);
Error in matlab.hwmgr.internal.Toolstrip/handleUserAddNonEnumDeviceStartPage (line 115)
obj.startNonEnumDeviceConfig(descriptor, "StartPage");
Error in matlab.hwmgr.internal.MessageLogger/logAndInvoke (line 59)
obj.(methodName)(evt.AffectedObject.(propName));
Error in matlab.hwmgr.internal.MessageLogger>@(src,evt)obj.logAndInvoke(src,evt,eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)) (line 83)
@(src,evt)obj.logAndInvoke(src, evt, eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)));
Error in matlabshared.mediator.internal.Publisher/setMediatorProp (line 68)
obj.Mediator.(src.Name) = evt.AffectedObject.(src.Name);
Error in matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
obj.PropEventListenerArray(end + 1) = obj.listener(propList(i).Name, ‘PostSet’, @obj.setMediatorProp);
Error in matlab.hwmgr.internal.MessageLogger/logAndSet (line 40)
obj.(propName) = propVal;
Error in matlab.hwmgr.internal.ClientAppStartPage/clientAddNonEnumDevice (line 225)
obj.logAndSet("UserAddNonEnumDeviceStartPage", descriptor);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
callback (1, 1) function_handle = @(msg)obj.Subject.(action)(msg)
Error in matlab.hwmgr.internal.MessageHandler/callbackHandler (line 157)
feval(obj.Subscriptions(msg.action), msg.params);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
obj.Subscriber = message.subscribe(obj.PubSubChannel, @(msg)obj.callbackHandler(msg));
Error in message.subscribe
Error in message.internal.executeCallback
> In matlabshared.mediator.internal/Publisher/setMediatorProp (line 68)
In matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
In matlab.hwmgr.internal/MessageLogger/logAndSet (line 40)
In matlab.hwmgr.internal/ClientAppStartPage/clientAddNonEnumDevice (line 225)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
In matlab.hwmgr.internal/MessageHandler/callbackHandler (line 157)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
In message.subscribe
In message.internal.executeCallback
Tried this on different Matlab versions R2024a,R2022b,R2020a. Laptop with Win 11
Any fix for this available, if not how to properly report bugs.When I want to create an Device via. "Modbus Explorer" it works flawless when I choose Modbus TCP. When I try to do the same with Modbus RTU, I get the following window. Only explenation window about config settings, but no Config setting available. Seems to me like a bug. Is there a fix for it ?
In Matlab I get this codes as feedback:
Warning: Error executing listener callback for PostSet event on UserAddNonEnumDeviceStartPage dynamic property in object of matlabshared.mediator.internal.Mediator class:
Error using matlab.ui.internal.toolstrip.DropDown/set.SelectedIndex
"SelectedIndex" property accepts an integer between 1 and the number of items.
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createDropDown (line 534)
valueWidget.SelectedIndex = 1;
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createWidget (line 436)
valueWidget = createDropDown(paramStruct.ParamID);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab (line 337)
valueWidget = createWidget(paramStruct);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler (line 118)
obj.populateTab();
Error in matlab.hwmgr.internal.Toolstrip/showModalTsTab (line 518)
obj.ModalTabHandler = matlab.hwmgr.internal.toolstrip.ParamTabHandler(…
Error in matlab.hwmgr.internal.Toolstrip/showNonEnumDeviceConfigTab (line 363)
obj.showModalTsTab(descriptor, @obj.confirmAddDevice, @()obj.cancelConfiguringDevice(cancelDestination));
Error in matlab.hwmgr.internal.Toolstrip/startNonEnumDeviceConfig (line 394)
obj.showNonEnumDeviceConfigTab(descriptor, cancelDestination);
Error in matlab.hwmgr.internal.Toolstrip/handleUserAddNonEnumDeviceStartPage (line 115)
obj.startNonEnumDeviceConfig(descriptor, "StartPage");
Error in matlab.hwmgr.internal.MessageLogger/logAndInvoke (line 59)
obj.(methodName)(evt.AffectedObject.(propName));
Error in matlab.hwmgr.internal.MessageLogger>@(src,evt)obj.logAndInvoke(src,evt,eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)) (line 83)
@(src,evt)obj.logAndInvoke(src, evt, eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)));
Error in matlabshared.mediator.internal.Publisher/setMediatorProp (line 68)
obj.Mediator.(src.Name) = evt.AffectedObject.(src.Name);
Error in matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
obj.PropEventListenerArray(end + 1) = obj.listener(propList(i).Name, ‘PostSet’, @obj.setMediatorProp);
Error in matlab.hwmgr.internal.MessageLogger/logAndSet (line 40)
obj.(propName) = propVal;
Error in matlab.hwmgr.internal.ClientAppStartPage/clientAddNonEnumDevice (line 225)
obj.logAndSet("UserAddNonEnumDeviceStartPage", descriptor);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
callback (1, 1) function_handle = @(msg)obj.Subject.(action)(msg)
Error in matlab.hwmgr.internal.MessageHandler/callbackHandler (line 157)
feval(obj.Subscriptions(msg.action), msg.params);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
obj.Subscriber = message.subscribe(obj.PubSubChannel, @(msg)obj.callbackHandler(msg));
Error in message.subscribe
Error in message.internal.executeCallback
> In matlabshared.mediator.internal/Publisher/setMediatorProp (line 68)
In matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
In matlab.hwmgr.internal/MessageLogger/logAndSet (line 40)
In matlab.hwmgr.internal/ClientAppStartPage/clientAddNonEnumDevice (line 225)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
In matlab.hwmgr.internal/MessageHandler/callbackHandler (line 157)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
In message.subscribe
In message.internal.executeCallback
Tried this on different Matlab versions R2024a,R2022b,R2020a. Laptop with Win 11
Any fix for this available, if not how to properly report bugs. When I want to create an Device via. "Modbus Explorer" it works flawless when I choose Modbus TCP. When I try to do the same with Modbus RTU, I get the following window. Only explenation window about config settings, but no Config setting available. Seems to me like a bug. Is there a fix for it ?
In Matlab I get this codes as feedback:
Warning: Error executing listener callback for PostSet event on UserAddNonEnumDeviceStartPage dynamic property in object of matlabshared.mediator.internal.Mediator class:
Error using matlab.ui.internal.toolstrip.DropDown/set.SelectedIndex
"SelectedIndex" property accepts an integer between 1 and the number of items.
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createDropDown (line 534)
valueWidget.SelectedIndex = 1;
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab/createWidget (line 436)
valueWidget = createDropDown(paramStruct.ParamID);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler/populateTab (line 337)
valueWidget = createWidget(paramStruct);
Error in matlab.hwmgr.internal.toolstrip.ParamTabHandler (line 118)
obj.populateTab();
Error in matlab.hwmgr.internal.Toolstrip/showModalTsTab (line 518)
obj.ModalTabHandler = matlab.hwmgr.internal.toolstrip.ParamTabHandler(…
Error in matlab.hwmgr.internal.Toolstrip/showNonEnumDeviceConfigTab (line 363)
obj.showModalTsTab(descriptor, @obj.confirmAddDevice, @()obj.cancelConfiguringDevice(cancelDestination));
Error in matlab.hwmgr.internal.Toolstrip/startNonEnumDeviceConfig (line 394)
obj.showNonEnumDeviceConfigTab(descriptor, cancelDestination);
Error in matlab.hwmgr.internal.Toolstrip/handleUserAddNonEnumDeviceStartPage (line 115)
obj.startNonEnumDeviceConfig(descriptor, "StartPage");
Error in matlab.hwmgr.internal.MessageLogger/logAndInvoke (line 59)
obj.(methodName)(evt.AffectedObject.(propName));
Error in matlab.hwmgr.internal.MessageLogger>@(src,evt)obj.logAndInvoke(src,evt,eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)) (line 83)
@(src,evt)obj.logAndInvoke(src, evt, eventsAndCallbacks(i,2),eventsAndCallbacks(i,1)));
Error in matlabshared.mediator.internal.Publisher/setMediatorProp (line 68)
obj.Mediator.(src.Name) = evt.AffectedObject.(src.Name);
Error in matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
obj.PropEventListenerArray(end + 1) = obj.listener(propList(i).Name, ‘PostSet’, @obj.setMediatorProp);
Error in matlab.hwmgr.internal.MessageLogger/logAndSet (line 40)
obj.(propName) = propVal;
Error in matlab.hwmgr.internal.ClientAppStartPage/clientAddNonEnumDevice (line 225)
obj.logAndSet("UserAddNonEnumDeviceStartPage", descriptor);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
callback (1, 1) function_handle = @(msg)obj.Subject.(action)(msg)
Error in matlab.hwmgr.internal.MessageHandler/callbackHandler (line 157)
feval(obj.Subscriptions(msg.action), msg.params);
Error in matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
obj.Subscriber = message.subscribe(obj.PubSubChannel, @(msg)obj.callbackHandler(msg));
Error in message.subscribe
Error in message.internal.executeCallback
> In matlabshared.mediator.internal/Publisher/setMediatorProp (line 68)
In matlabshared.mediator.internal.Publisher>@(varargin)obj.setMediatorProp(varargin{:}) (line 62)
In matlab.hwmgr.internal/MessageLogger/logAndSet (line 40)
In matlab.hwmgr.internal/ClientAppStartPage/clientAddNonEnumDevice (line 225)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.Subject.(action)(msg) (line 71)
In matlab.hwmgr.internal/MessageHandler/callbackHandler (line 157)
In matlab.hwmgr.internal.MessageHandler>@(msg)obj.callbackHandler(msg) (line 135)
In message.subscribe
In message.internal.executeCallback
Tried this on different Matlab versions R2024a,R2022b,R2020a. Laptop with Win 11
Any fix for this available, if not how to properly report bugs. modbus, modbus explorer, rtu, bug, overview, error MATLAB Answers — New Questions
Is it possible to assign variables in the workspace to other variables using for loop?
I have variables like a_1_1, a_1_2, a_1_3, a_2_1, a_2_2, etc…… in the workspace. I want to assign these variables to another variable inside a for loop. Such that for each loop each variable will be loaded. For instance,
for i=1:100
for j=1:3
e=a_i_j
end
end
The abovementioned is just a pseudo code only for understanding.
How this can be done inside a for loop?I have variables like a_1_1, a_1_2, a_1_3, a_2_1, a_2_2, etc…… in the workspace. I want to assign these variables to another variable inside a for loop. Such that for each loop each variable will be loaded. For instance,
for i=1:100
for j=1:3
e=a_i_j
end
end
The abovementioned is just a pseudo code only for understanding.
How this can be done inside a for loop? I have variables like a_1_1, a_1_2, a_1_3, a_2_1, a_2_2, etc…… in the workspace. I want to assign these variables to another variable inside a for loop. Such that for each loop each variable will be loaded. For instance,
for i=1:100
for j=1:3
e=a_i_j
end
end
The abovementioned is just a pseudo code only for understanding.
How this can be done inside a for loop? image processing, image analysis, image segmentation, image acquisition, digital signal processing, digital image processing, signal processing, signal, mathematics, deep learning, machine learning, biomedical signal, ecg, multiplication MATLAB Answers — New Questions
Roadrunner unknown option suppressCrashHandlerFailures
Roadrunner unknown option suppressCrashHandlerFailures when lanuch RoadrunnerRoadrunner unknown option suppressCrashHandlerFailures when lanuch Roadrunner Roadrunner unknown option suppressCrashHandlerFailures when lanuch Roadrunner roadrunner unknown option suppresscrashhandlerfail MATLAB Answers — New Questions
decsg fails to decompose a few ellipses out of a set of 19 for unknown reason
Hello all, I am attempting to generate a decomposed geometry matrix of various ellipses in a square region using decsg in order to then extrude the geometry into 3D and mesh for use in a static structural model in the pde toolbox.
However, some of the ellipses (#4 when included with #s 1-3 or #19 when included with the rest) cause decsg to fail when included in the decsg inputs as so:
Error using decsg
Unable to decompose objects in the geometry description matrix into minimal regions.
Error in scatteredEllipses (line 42)
[dl, ~] = decsg(gd,sf,ns);
The scatteredEllipses function is presented below in its entirety, I have also attached the force_x, force_y, and force_z variables within forces.mat which are 512×512 double matrices of force magnitudes which represent desired ellipse locations.
clearvars -except force*; close all;
%% Fit ellipses to each traction island
tractionMask = abs(force_x) + abs(force_y) + abs(force_z); %combine x,y,z tractions to create mask of all nonzero elements
tractionMask(tractionMask ~= 0) = 1; %convert nonzero elements to 1
cc = bwconncomp(tractionMask); %get all connected ellipse regions
s = regionprops(cc,{‘Centroid’,’Orientation’,’MajorAxisLength’,’MinorAxisLength’}); %fit ellipse parameters to each detected region
figure, imshow(tractionMask,[]), hold on
theta = linspace(0,2*pi);
orientationList = zeros(size(s,1),2);
for i = 1:length(s)
col = (s(i).MajorAxisLength/2)*cos(theta);
row = (s(i).MinorAxisLength/2)*sin(theta);
M = makehgtform(‘translate’,[s(i).Centroid, 0],’zrotate’,deg2rad(-1*s(i).Orientation));
[orientationList(i,1),orientationList(i,2)] = pol2cart(deg2rad(-1*s(i).Orientation),1);
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];
plot(D(1,:),D(2,:),’r’,’LineWidth’,2); hold on
s(i).Orientation = -1 * s(i).Orientation; %convert orientation to xy coordinate frame
end
%axis xy
hold off
%% Generate geometry
meshPtsFwdSol = 512;
halfSide = meshPtsFwdSol/2;
bound = [3; 4; -halfSide; halfSide; halfSide; -halfSide; halfSide; halfSide; -halfSide; -halfSide];
ns = char(‘bound’);
sf = ‘bound’;
full = 1:length(s);
workingSubset = 4:length(s)-1;
g = 1;
for i = workingSubset %switch with full to cause error
sf = [sf,’+elli’,num2str(g)];
ns = char(ns,[‘elli’,num2str(g)]);
elli(:,g) = [4; s(i).Centroid(1)-halfSide; s(i).Centroid(2)-halfSide; s(i).MajorAxisLength/2; s(i).MinorAxisLength/2; deg2rad(s(i).Orientation); 0; 0; 0; 0];
g = g + 1;
end
gd = [bound,elli];
ns = ns’;
[dl, ~] = decsg(gd,sf,ns);
%figure,pdegplot(dl,’EdgeLabels’,’on’,’FaceLabels’,’on’)
pdem = createpde;
g = geometryFromEdges(pdem,dl);
%figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’)
facets = facetAnalyticGeometry(pdem,g,0);
gm = analyticToDiscrete(facets);
pdem.Geometry = gm;
figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’)Hello all, I am attempting to generate a decomposed geometry matrix of various ellipses in a square region using decsg in order to then extrude the geometry into 3D and mesh for use in a static structural model in the pde toolbox.
However, some of the ellipses (#4 when included with #s 1-3 or #19 when included with the rest) cause decsg to fail when included in the decsg inputs as so:
Error using decsg
Unable to decompose objects in the geometry description matrix into minimal regions.
Error in scatteredEllipses (line 42)
[dl, ~] = decsg(gd,sf,ns);
The scatteredEllipses function is presented below in its entirety, I have also attached the force_x, force_y, and force_z variables within forces.mat which are 512×512 double matrices of force magnitudes which represent desired ellipse locations.
clearvars -except force*; close all;
%% Fit ellipses to each traction island
tractionMask = abs(force_x) + abs(force_y) + abs(force_z); %combine x,y,z tractions to create mask of all nonzero elements
tractionMask(tractionMask ~= 0) = 1; %convert nonzero elements to 1
cc = bwconncomp(tractionMask); %get all connected ellipse regions
s = regionprops(cc,{‘Centroid’,’Orientation’,’MajorAxisLength’,’MinorAxisLength’}); %fit ellipse parameters to each detected region
figure, imshow(tractionMask,[]), hold on
theta = linspace(0,2*pi);
orientationList = zeros(size(s,1),2);
for i = 1:length(s)
col = (s(i).MajorAxisLength/2)*cos(theta);
row = (s(i).MinorAxisLength/2)*sin(theta);
M = makehgtform(‘translate’,[s(i).Centroid, 0],’zrotate’,deg2rad(-1*s(i).Orientation));
[orientationList(i,1),orientationList(i,2)] = pol2cart(deg2rad(-1*s(i).Orientation),1);
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];
plot(D(1,:),D(2,:),’r’,’LineWidth’,2); hold on
s(i).Orientation = -1 * s(i).Orientation; %convert orientation to xy coordinate frame
end
%axis xy
hold off
%% Generate geometry
meshPtsFwdSol = 512;
halfSide = meshPtsFwdSol/2;
bound = [3; 4; -halfSide; halfSide; halfSide; -halfSide; halfSide; halfSide; -halfSide; -halfSide];
ns = char(‘bound’);
sf = ‘bound’;
full = 1:length(s);
workingSubset = 4:length(s)-1;
g = 1;
for i = workingSubset %switch with full to cause error
sf = [sf,’+elli’,num2str(g)];
ns = char(ns,[‘elli’,num2str(g)]);
elli(:,g) = [4; s(i).Centroid(1)-halfSide; s(i).Centroid(2)-halfSide; s(i).MajorAxisLength/2; s(i).MinorAxisLength/2; deg2rad(s(i).Orientation); 0; 0; 0; 0];
g = g + 1;
end
gd = [bound,elli];
ns = ns’;
[dl, ~] = decsg(gd,sf,ns);
%figure,pdegplot(dl,’EdgeLabels’,’on’,’FaceLabels’,’on’)
pdem = createpde;
g = geometryFromEdges(pdem,dl);
%figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’)
facets = facetAnalyticGeometry(pdem,g,0);
gm = analyticToDiscrete(facets);
pdem.Geometry = gm;
figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’) Hello all, I am attempting to generate a decomposed geometry matrix of various ellipses in a square region using decsg in order to then extrude the geometry into 3D and mesh for use in a static structural model in the pde toolbox.
However, some of the ellipses (#4 when included with #s 1-3 or #19 when included with the rest) cause decsg to fail when included in the decsg inputs as so:
Error using decsg
Unable to decompose objects in the geometry description matrix into minimal regions.
Error in scatteredEllipses (line 42)
[dl, ~] = decsg(gd,sf,ns);
The scatteredEllipses function is presented below in its entirety, I have also attached the force_x, force_y, and force_z variables within forces.mat which are 512×512 double matrices of force magnitudes which represent desired ellipse locations.
clearvars -except force*; close all;
%% Fit ellipses to each traction island
tractionMask = abs(force_x) + abs(force_y) + abs(force_z); %combine x,y,z tractions to create mask of all nonzero elements
tractionMask(tractionMask ~= 0) = 1; %convert nonzero elements to 1
cc = bwconncomp(tractionMask); %get all connected ellipse regions
s = regionprops(cc,{‘Centroid’,’Orientation’,’MajorAxisLength’,’MinorAxisLength’}); %fit ellipse parameters to each detected region
figure, imshow(tractionMask,[]), hold on
theta = linspace(0,2*pi);
orientationList = zeros(size(s,1),2);
for i = 1:length(s)
col = (s(i).MajorAxisLength/2)*cos(theta);
row = (s(i).MinorAxisLength/2)*sin(theta);
M = makehgtform(‘translate’,[s(i).Centroid, 0],’zrotate’,deg2rad(-1*s(i).Orientation));
[orientationList(i,1),orientationList(i,2)] = pol2cart(deg2rad(-1*s(i).Orientation),1);
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];
plot(D(1,:),D(2,:),’r’,’LineWidth’,2); hold on
s(i).Orientation = -1 * s(i).Orientation; %convert orientation to xy coordinate frame
end
%axis xy
hold off
%% Generate geometry
meshPtsFwdSol = 512;
halfSide = meshPtsFwdSol/2;
bound = [3; 4; -halfSide; halfSide; halfSide; -halfSide; halfSide; halfSide; -halfSide; -halfSide];
ns = char(‘bound’);
sf = ‘bound’;
full = 1:length(s);
workingSubset = 4:length(s)-1;
g = 1;
for i = workingSubset %switch with full to cause error
sf = [sf,’+elli’,num2str(g)];
ns = char(ns,[‘elli’,num2str(g)]);
elli(:,g) = [4; s(i).Centroid(1)-halfSide; s(i).Centroid(2)-halfSide; s(i).MajorAxisLength/2; s(i).MinorAxisLength/2; deg2rad(s(i).Orientation); 0; 0; 0; 0];
g = g + 1;
end
gd = [bound,elli];
ns = ns’;
[dl, ~] = decsg(gd,sf,ns);
%figure,pdegplot(dl,’EdgeLabels’,’on’,’FaceLabels’,’on’)
pdem = createpde;
g = geometryFromEdges(pdem,dl);
%figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’)
facets = facetAnalyticGeometry(pdem,g,0);
gm = analyticToDiscrete(facets);
pdem.Geometry = gm;
figure,pdegplot(pdem,’EdgeLabels’,’on’,’FaceLabels’,’on’) pde, pdetoolbox, decsg MATLAB Answers — New Questions
plotting power spectrum density
I have 2 .dat file with me one of amplitude and one of time and I want to do the powerspectrum analysis of the data. Can anyone please help me in creating a time vector for doing FFTI have 2 .dat file with me one of amplitude and one of time and I want to do the powerspectrum analysis of the data. Can anyone please help me in creating a time vector for doing FFT I have 2 .dat file with me one of amplitude and one of time and I want to do the powerspectrum analysis of the data. Can anyone please help me in creating a time vector for doing FFT fft, time vector MATLAB Answers — New Questions
Simulink Test Manager – create from model file and test harness seperate
I have a simulink model file, and a test harness file for that model. But the model was not linked to test harness file.
Actually i don’t want to modify anything in original model, so i don’t want to link model to test harmess.
So when i create test case in test manager, it can not found the test harness information. So is there anyway to directly assign model and test harness in a testcase by any API?I have a simulink model file, and a test harness file for that model. But the model was not linked to test harness file.
Actually i don’t want to modify anything in original model, so i don’t want to link model to test harmess.
So when i create test case in test manager, it can not found the test harness information. So is there anyway to directly assign model and test harness in a testcase by any API? I have a simulink model file, and a test harness file for that model. But the model was not linked to test harness file.
Actually i don’t want to modify anything in original model, so i don’t want to link model to test harmess.
So when i create test case in test manager, it can not found the test harness information. So is there anyway to directly assign model and test harness in a testcase by any API? test manager, simulink, test MATLAB Answers — New Questions
エンジントルクの求め方
Model Engine Timing Using Triggered Subsystems – MATLAB & Simulink – MathWorks
Equation 4でのTorqueの求め方の出典を教えてくださいModel Engine Timing Using Triggered Subsystems – MATLAB & Simulink – MathWorks
Equation 4でのTorqueの求め方の出典を教えてください Model Engine Timing Using Triggered Subsystems – MATLAB & Simulink – MathWorks
Equation 4でのTorqueの求め方の出典を教えてください torque MATLAB Answers — New Questions
How to define a function whose number of outputs depend on an input parameter value?
Say for M = 4, I have a code below.
function [c,ceq] = Constraint(M)
c = [];
for i=1:M
ceq_{i} = i;
end
ceq = [ceq_{1} ceq_{2} ceq_{3} ceq_{4}];
end
My question is for bigger values of M, how do I define the last ceq so that I don’t have to write each ceq_{i}’s individually?Say for M = 4, I have a code below.
function [c,ceq] = Constraint(M)
c = [];
for i=1:M
ceq_{i} = i;
end
ceq = [ceq_{1} ceq_{2} ceq_{3} ceq_{4}];
end
My question is for bigger values of M, how do I define the last ceq so that I don’t have to write each ceq_{i}’s individually? Say for M = 4, I have a code below.
function [c,ceq] = Constraint(M)
c = [];
for i=1:M
ceq_{i} = i;
end
ceq = [ceq_{1} ceq_{2} ceq_{3} ceq_{4}];
end
My question is for bigger values of M, how do I define the last ceq so that I don’t have to write each ceq_{i}’s individually? function, for loop, output MATLAB Answers — New Questions
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation. (asbQuadcopter-parrot mambo-R2021b)
Sir,
I received the following error while trying to build ‘asbQuadcopter fileSir,
I received the following error while trying to build ‘asbQuadcopter file Sir,
I received the following error while trying to build ‘asbQuadcopter file parrot minidrone error MATLAB Answers — New Questions
How to use function ping in Matlab 2024?
Hello world,
I have a problem with database connection in Matlab 2024. I think it is because of the lack some toolbox packages, which are not there.
Can someone please answer me, what additional toolbox packages do I need beside <Database> toolbox to be able to run <ping.m> function?
Thanks,
CarolineHello world,
I have a problem with database connection in Matlab 2024. I think it is because of the lack some toolbox packages, which are not there.
Can someone please answer me, what additional toolbox packages do I need beside <Database> toolbox to be able to run <ping.m> function?
Thanks,
Caroline Hello world,
I have a problem with database connection in Matlab 2024. I think it is because of the lack some toolbox packages, which are not there.
Can someone please answer me, what additional toolbox packages do I need beside <Database> toolbox to be able to run <ping.m> function?
Thanks,
Caroline ping, database connection MATLAB Answers — New Questions
Warning: Error updating FunctionLine. The following error was reported evaluating the function in FunctionLine update:Array indices must be positive integers or logical value
A=10^(-4);
l= 250*10^(-6);
g=0.1517;
e=0.132205;
d=0.142;
K= 2.34*10^(-12);
Yr = @ (w) w*A*e*{d(1-K)+gK}/[l{(1-K)^2 +(gK)^2} ];
fplot(Yr,[10,100],"r")
xlabel(‘Frequency’)
ylabel(‘Conductance’)
grid onA=10^(-4);
l= 250*10^(-6);
g=0.1517;
e=0.132205;
d=0.142;
K= 2.34*10^(-12);
Yr = @ (w) w*A*e*{d(1-K)+gK}/[l{(1-K)^2 +(gK)^2} ];
fplot(Yr,[10,100],"r")
xlabel(‘Frequency’)
ylabel(‘Conductance’)
grid on A=10^(-4);
l= 250*10^(-6);
g=0.1517;
e=0.132205;
d=0.142;
K= 2.34*10^(-12);
Yr = @ (w) w*A*e*{d(1-K)+gK}/[l{(1-K)^2 +(gK)^2} ];
fplot(Yr,[10,100],"r")
xlabel(‘Frequency’)
ylabel(‘Conductance’)
grid on matlab MATLAB Answers — New Questions
C2000 use the CCS project to simulate a model like HIL
Dear Support Team,
I am wondering whether there is a quick guide on how to use TI launchpad DELFINO F28379D with a Simulink model from a precompiled Code Composer Studio project in real time.
What are the requirements to do this task? The task to perform is to have the control implemented via the CCS on the launchpad running in Debug mode, and using UART to send data and receive feedback real time.
Thanks in advanceDear Support Team,
I am wondering whether there is a quick guide on how to use TI launchpad DELFINO F28379D with a Simulink model from a precompiled Code Composer Studio project in real time.
What are the requirements to do this task? The task to perform is to have the control implemented via the CCS on the launchpad running in Debug mode, and using UART to send data and receive feedback real time.
Thanks in advance Dear Support Team,
I am wondering whether there is a quick guide on how to use TI launchpad DELFINO F28379D with a Simulink model from a precompiled Code Composer Studio project in real time.
What are the requirements to do this task? The task to perform is to have the control implemented via the CCS on the launchpad running in Debug mode, and using UART to send data and receive feedback real time.
Thanks in advance launchpad, hil, simulink, delfino, c2000 MATLAB Answers — New Questions
How can check if GUI fully created?
Hello all,
So I have an app which create additional tabs with content(tables, plots etc.) somewhere in the middle of process. I have cover this code with progress dialog, but after this dialog dissapear it takes for app litterally additional ~5min to actual make this elements fully availiable.
So my question: Is it possible somehow check if app finish their routine or not?Hello all,
So I have an app which create additional tabs with content(tables, plots etc.) somewhere in the middle of process. I have cover this code with progress dialog, but after this dialog dissapear it takes for app litterally additional ~5min to actual make this elements fully availiable.
So my question: Is it possible somehow check if app finish their routine or not? Hello all,
So I have an app which create additional tabs with content(tables, plots etc.) somewhere in the middle of process. I have cover this code with progress dialog, but after this dialog dissapear it takes for app litterally additional ~5min to actual make this elements fully availiable.
So my question: Is it possible somehow check if app finish their routine or not? matlab gui, app designer MATLAB Answers — New Questions
Genetic Algorithm based on mppt for off-grid solar pv system write a code for me… i need help to integrate with the simulink parameters and reduce errors in code
function best_duty_cycle = testing1(~, I_pv )
% Prompt the user to enter the values of the input arguments
V_pv = 210
I_pv = 22
population_size = 2
max_generations = 60
% Initialize the population with random duty cycles
population = rand(population_size, 1);
% Initialize the best duty cycle
best_duty_cycle = population(1);
% Initialize the best fitness
best_fitness = fitness(best_duty_cycle, V_pv, I_pv);
% Loop through the generations
for generation = 1:max_generations
% Evaluate the fitness of the population
fitness_values = arrayfun(@(x) fitness(x, V_pv, I_pv), population);
% Select the individuals for reproduction
selected_indices = randsample(1:length(population), length(population), true, fitness_values);
% Perform crossover
for i = 1:2:length(population)
parent1 = population(selected_indices(i));
parent2 = population(selected_indices(i+1));
crossover_points = randi([1, length(parent1)], 1);
child1 = [parent1(1:crossover_points), parent2(crossover_points+1:end)];
child2 = [parent2(1:crossover_points), parent1(crossover_points+1:end)];
population([i, i+1]) = [child1, child2];
end
% Perform mutation
mutation_probabilities = rand(length(population), 1);
mutation_indices = find(mutation_probabilities < 0.01);
population(mutation_indices) = population(mutation_indices) + 0.1 * randn(length(mutation_indices), 1);
% Update the best duty cycle and fitness
current_best_index = find(fitness_values == max(fitness_values));
if fitness_values(current_best_index) > best_fitness
best_duty_cycle = population(current_best_index);
best_fitness = fitness_values(current_best_index);
end
end
end
function fitness = fitness(best_duty_cycle, V_pv, I_pv)
% Calculate the power
power = best_duty_cycle .* V_pv .* I_pv;
% Calculate the fitness
fitness = sum(power);
endfunction best_duty_cycle = testing1(~, I_pv )
% Prompt the user to enter the values of the input arguments
V_pv = 210
I_pv = 22
population_size = 2
max_generations = 60
% Initialize the population with random duty cycles
population = rand(population_size, 1);
% Initialize the best duty cycle
best_duty_cycle = population(1);
% Initialize the best fitness
best_fitness = fitness(best_duty_cycle, V_pv, I_pv);
% Loop through the generations
for generation = 1:max_generations
% Evaluate the fitness of the population
fitness_values = arrayfun(@(x) fitness(x, V_pv, I_pv), population);
% Select the individuals for reproduction
selected_indices = randsample(1:length(population), length(population), true, fitness_values);
% Perform crossover
for i = 1:2:length(population)
parent1 = population(selected_indices(i));
parent2 = population(selected_indices(i+1));
crossover_points = randi([1, length(parent1)], 1);
child1 = [parent1(1:crossover_points), parent2(crossover_points+1:end)];
child2 = [parent2(1:crossover_points), parent1(crossover_points+1:end)];
population([i, i+1]) = [child1, child2];
end
% Perform mutation
mutation_probabilities = rand(length(population), 1);
mutation_indices = find(mutation_probabilities < 0.01);
population(mutation_indices) = population(mutation_indices) + 0.1 * randn(length(mutation_indices), 1);
% Update the best duty cycle and fitness
current_best_index = find(fitness_values == max(fitness_values));
if fitness_values(current_best_index) > best_fitness
best_duty_cycle = population(current_best_index);
best_fitness = fitness_values(current_best_index);
end
end
end
function fitness = fitness(best_duty_cycle, V_pv, I_pv)
% Calculate the power
power = best_duty_cycle .* V_pv .* I_pv;
% Calculate the fitness
fitness = sum(power);
end function best_duty_cycle = testing1(~, I_pv )
% Prompt the user to enter the values of the input arguments
V_pv = 210
I_pv = 22
population_size = 2
max_generations = 60
% Initialize the population with random duty cycles
population = rand(population_size, 1);
% Initialize the best duty cycle
best_duty_cycle = population(1);
% Initialize the best fitness
best_fitness = fitness(best_duty_cycle, V_pv, I_pv);
% Loop through the generations
for generation = 1:max_generations
% Evaluate the fitness of the population
fitness_values = arrayfun(@(x) fitness(x, V_pv, I_pv), population);
% Select the individuals for reproduction
selected_indices = randsample(1:length(population), length(population), true, fitness_values);
% Perform crossover
for i = 1:2:length(population)
parent1 = population(selected_indices(i));
parent2 = population(selected_indices(i+1));
crossover_points = randi([1, length(parent1)], 1);
child1 = [parent1(1:crossover_points), parent2(crossover_points+1:end)];
child2 = [parent2(1:crossover_points), parent1(crossover_points+1:end)];
population([i, i+1]) = [child1, child2];
end
% Perform mutation
mutation_probabilities = rand(length(population), 1);
mutation_indices = find(mutation_probabilities < 0.01);
population(mutation_indices) = population(mutation_indices) + 0.1 * randn(length(mutation_indices), 1);
% Update the best duty cycle and fitness
current_best_index = find(fitness_values == max(fitness_values));
if fitness_values(current_best_index) > best_fitness
best_duty_cycle = population(current_best_index);
best_fitness = fitness_values(current_best_index);
end
end
end
function fitness = fitness(best_duty_cycle, V_pv, I_pv)
% Calculate the power
power = best_duty_cycle .* V_pv .* I_pv;
% Calculate the fitness
fitness = sum(power);
end ga based MATLAB Answers — New Questions
Symbolically solving an equation with multiple variables
This is the nozzle expansion ratio equation and I am attempting to solve for the exit pressure. It is quite complex to rearrange for Pe (exit pressure) by hand so I figured I would put it into Matlab and solve symbollically. I keep getting an empty vector for solveEqn… I’m quite inexperienced with solving symbollically in Matlab so I would appreciate some help. Thank you.
syms Pe k A_ratio Pc
A_ratio = 2.06265092035577;
k = 1.1876;
Pc = 3447378.65;
eqn = ((k+1)/2)^(1/(k+1))*(Pe/Pc)^1/k*sqrt((k+1)/(k-1))*(1-(Pe/Pc)^(k-1)/k) == A_ratio;
solveEqn = solve(A_ratio, Pe);This is the nozzle expansion ratio equation and I am attempting to solve for the exit pressure. It is quite complex to rearrange for Pe (exit pressure) by hand so I figured I would put it into Matlab and solve symbollically. I keep getting an empty vector for solveEqn… I’m quite inexperienced with solving symbollically in Matlab so I would appreciate some help. Thank you.
syms Pe k A_ratio Pc
A_ratio = 2.06265092035577;
k = 1.1876;
Pc = 3447378.65;
eqn = ((k+1)/2)^(1/(k+1))*(Pe/Pc)^1/k*sqrt((k+1)/(k-1))*(1-(Pe/Pc)^(k-1)/k) == A_ratio;
solveEqn = solve(A_ratio, Pe); This is the nozzle expansion ratio equation and I am attempting to solve for the exit pressure. It is quite complex to rearrange for Pe (exit pressure) by hand so I figured I would put it into Matlab and solve symbollically. I keep getting an empty vector for solveEqn… I’m quite inexperienced with solving symbollically in Matlab so I would appreciate some help. Thank you.
syms Pe k A_ratio Pc
A_ratio = 2.06265092035577;
k = 1.1876;
Pc = 3447378.65;
eqn = ((k+1)/2)^(1/(k+1))*(Pe/Pc)^1/k*sqrt((k+1)/(k-1))*(1-(Pe/Pc)^(k-1)/k) == A_ratio;
solveEqn = solve(A_ratio, Pe); symbolic, equation MATLAB Answers — New Questions
REGENERATIVE BRAKING FOR EV
hi is it possible to design an anti lock regenerative system ? i have the the ABS system already and i’m trying to figure out how to intergrate the regen breaking parthi is it possible to design an anti lock regenerative system ? i have the the ABS system already and i’m trying to figure out how to intergrate the regen breaking part hi is it possible to design an anti lock regenerative system ? i have the the ABS system already and i’m trying to figure out how to intergrate the regen breaking part control MATLAB Answers — New Questions