Tag Archives: matlab
Will multiple instances of a C++ S-function in Simulink sharing the same memory pool cause issues with static variables?
I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function?I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function? I have written an S-function with a C++ class with static attributes. Given how static variables share a common memory space across instances, if I have multiple copies of the S-function, will changes to the static attributes affect the rest of the S-function instances?
How do I create a separate memory space for each S-Function? static, attribute, class, cpp, sfunction, workvector MATLAB Answers — New Questions
Attempting to fit data with a sigmoid curve, but not an option in curvefitter toolbox
I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’ I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
‘a/(1+exp(-b*(x-c)))’ curvefitter, sigmoid MATLAB Answers — New Questions
matlab code to design and analyze Racetrack resonator
How to design an ractrack resonator in matlab for biosensing applicationsHow to design an ractrack resonator in matlab for biosensing applications How to design an ractrack resonator in matlab for biosensing applications integrated photonics MATLAB Answers — New Questions
Help Index exceeds the number of array elements?
The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error.The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error. The error i am recieving is:
Index exceeds the number of array elements. Index must not exceed 0.
Error Line 39: disp([‘Book 1: ‘, num2str(x(1))]);
I bellive the issues might be occuring in:
Line 34: options = optimoptions(‘linprog’, ‘Display’, ‘off’); or
Line 35 [x, fval] = linprog(f, A, b, [], [], lb, [], options);
But can’t find what is causing the error. optimization, index MATLAB Answers — New Questions
How to resolve error showing ‘Unexpected matlab expression’?????
I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me…I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me… I am getting an error as Unexpected matlab expreesion; but i am neither be able to find out which expreesion is wrong and nor be able to resolve this error. Please help me… unexpected matlab expression MATLAB Answers — New Questions
Using system composer, it is possible to create a report with the sequence diagrams?
I´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
endI´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
end I´m using system composer, and i want to create a report with the views and sequence diagrams that i have. I have this code to generate the report and add the views, but i don´t know if there is a way to add too the sequence diagrams because there is nothing like "SequenceDiagramFinder".
Here is the code for the views:
model = systemcomposer.loadModel(model_name);
rpt = slreportgen.report.Report(output="ViewFinderReport",…
CompileModelBeforeReporting=false);
viewFinder = ViewFinder(model_name);
chapter = Chapter("Title","Views");
while hasNext(viewFinder)
view = next(viewFinder);
sect = Section("Title",view.Name);
add(sect,view);
add(chapter,sect);
end system composer, views, sequence diagrams MATLAB Answers — New Questions
How to use Individual License file in MATLAB Docker?
Hello, I am trying to use my Individual License file in a MATLAB Docker container but I get the error of ‘hostid of your computer does not match the hostid of your license file’.
I can login to the container by using my email and password but this is NOT ideal since the login session expires after some time and need to relogin again. I want to run this headless so if I can pass in a license file then I don’t have to keep logging in manually.
I downloaded the Individual License file from the online License Center portal Install and Activate tab. This downloaded a license.lic file which I pass into the Docker container.
My Docker run command:
docker run -it –rm -p 5901:5901 -p 6080:6080 -v ~/ivy:/ivy -e MLM_LICENSE_FILE=/ivy/license.lic mathworks/matlab:r2021b -vnc
License error:Hello, I am trying to use my Individual License file in a MATLAB Docker container but I get the error of ‘hostid of your computer does not match the hostid of your license file’.
I can login to the container by using my email and password but this is NOT ideal since the login session expires after some time and need to relogin again. I want to run this headless so if I can pass in a license file then I don’t have to keep logging in manually.
I downloaded the Individual License file from the online License Center portal Install and Activate tab. This downloaded a license.lic file which I pass into the Docker container.
My Docker run command:
docker run -it –rm -p 5901:5901 -p 6080:6080 -v ~/ivy:/ivy -e MLM_LICENSE_FILE=/ivy/license.lic mathworks/matlab:r2021b -vnc
License error: Hello, I am trying to use my Individual License file in a MATLAB Docker container but I get the error of ‘hostid of your computer does not match the hostid of your license file’.
I can login to the container by using my email and password but this is NOT ideal since the login session expires after some time and need to relogin again. I want to run this headless so if I can pass in a license file then I don’t have to keep logging in manually.
I downloaded the Individual License file from the online License Center portal Install and Activate tab. This downloaded a license.lic file which I pass into the Docker container.
My Docker run command:
docker run -it –rm -p 5901:5901 -p 6080:6080 -v ~/ivy:/ivy -e MLM_LICENSE_FILE=/ivy/license.lic mathworks/matlab:r2021b -vnc
License error: docker, license MATLAB Answers — New Questions
Library mblibv1 not found in R2020a
I am using MATLAB R2020a where SimScape libraries are also installed. But I couldn’t find mbliv1 library. Can you please let me know where can I find it? Whether it is deprecated in R2020a?I am using MATLAB R2020a where SimScape libraries are also installed. But I couldn’t find mbliv1 library. Can you please let me know where can I find it? Whether it is deprecated in R2020a? I am using MATLAB R2020a where SimScape libraries are also installed. But I couldn’t find mbliv1 library. Can you please let me know where can I find it? Whether it is deprecated in R2020a? simscape MATLAB Answers — New Questions
How can I use a previous version of Matlab ? I using Matlab 2022b and I would like to run some script in a previous version 2021a. Thanks
How can I use a previous version of Matlab ? I using Matlab 2022b and I would like to run some script in a previous version 2021a.
ThanksHow can I use a previous version of Matlab ? I using Matlab 2022b and I would like to run some script in a previous version 2021a.
Thanks How can I use a previous version of Matlab ? I using Matlab 2022b and I would like to run some script in a previous version 2021a.
Thanks matlab version MATLAB Answers — New Questions
How can I export Roboflow annotation to work in Matlab
Hello! I’m using annotations to create bounding boxes on my images to train a model. To export the dataset created on Roboflow, we can export in different ways, like COCO segmentation Json files, or TXT YOLO oriented bounding boxes, or CSV tensorflow/ CSV keras. The downloaded files comes with the images and labels created in train, test and validation. So I have the images, the labels with coordinates from each image that I’m creating the Annotation. But I don’t know how am I work with those files on Matlab. Anyone can help me with this problem?Hello! I’m using annotations to create bounding boxes on my images to train a model. To export the dataset created on Roboflow, we can export in different ways, like COCO segmentation Json files, or TXT YOLO oriented bounding boxes, or CSV tensorflow/ CSV keras. The downloaded files comes with the images and labels created in train, test and validation. So I have the images, the labels with coordinates from each image that I’m creating the Annotation. But I don’t know how am I work with those files on Matlab. Anyone can help me with this problem? Hello! I’m using annotations to create bounding boxes on my images to train a model. To export the dataset created on Roboflow, we can export in different ways, like COCO segmentation Json files, or TXT YOLO oriented bounding boxes, or CSV tensorflow/ CSV keras. The downloaded files comes with the images and labels created in train, test and validation. So I have the images, the labels with coordinates from each image that I’m creating the Annotation. But I don’t know how am I work with those files on Matlab. Anyone can help me with this problem? matlab, deep learning, neural network, neural networks, machine learning, image processing MATLAB Answers — New Questions
How can i encrypt image by xoring?
How can i encrypt image by xoring?How can i encrypt image by xoring? How can i encrypt image by xoring? af MATLAB Answers — New Questions
Difference between local time and “created_at
Hello
The time returned by "created_at" does not correspond to the local time
e.g. 18:54:33.401 -> Message:{"channel_id":2499901, "created_at": "2024-08-21T16:54:31Z"….}
although my profile is correctly filled in, the time indicated on the plot is correct
Should I add the term: ?timezone = Europe%2FParis
if where please I do not have a field in "channel setting" to add it
Thank you in advance.Hello
The time returned by "created_at" does not correspond to the local time
e.g. 18:54:33.401 -> Message:{"channel_id":2499901, "created_at": "2024-08-21T16:54:31Z"….}
although my profile is correctly filled in, the time indicated on the plot is correct
Should I add the term: ?timezone = Europe%2FParis
if where please I do not have a field in "channel setting" to add it
Thank you in advance. Hello
The time returned by "created_at" does not correspond to the local time
e.g. 18:54:33.401 -> Message:{"channel_id":2499901, "created_at": "2024-08-21T16:54:31Z"….}
although my profile is correctly filled in, the time indicated on the plot is correct
Should I add the term: ?timezone = Europe%2FParis
if where please I do not have a field in "channel setting" to add it
Thank you in advance. timezone MATLAB Answers — New Questions
Two step ahead autoregressive prediction
Is it possible to use the AR function in Matlab to train models such as:
y(t+2)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
rather than:
y(t+1)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
I want to avoid predicting y(t+2) using y(t+1).
Many thanksIs it possible to use the AR function in Matlab to train models such as:
y(t+2)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
rather than:
y(t+1)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
I want to avoid predicting y(t+2) using y(t+1).
Many thanks Is it possible to use the AR function in Matlab to train models such as:
y(t+2)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
rather than:
y(t+1)=a(1)u(t-1)+a(2)u(t-2)+…+a(p)u(t-p)
I want to avoid predicting y(t+2) using y(t+1).
Many thanks matlab, autoregression MATLAB Answers — New Questions
Problem running spm12 using R2019a on Centos 7
When I issue the spm command, it displays the startup window. After clicking on a button, I get:
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkObject’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_register_static: assertion ‘parent_type > 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkBuildable’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_interface_add_prerequisite: assertion ‘G_TYPE_IS_INTERFACE (interface_type)’ failed
(MATLAB:374189): GLib-CRITICAL **: 09:26:25.382: g_once_init_leave: assertion ‘result != 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.383: g_type_register_static: assertion ‘parent_type > 0’ failed
and then it freezes.
OS: Linux 3.10.0-957.el7.x86_64
Compiler: gcc 6.3.0
Glib: 2.42.2
Java: 1.8.0_211
Any ideas on what needs to be fixed?When I issue the spm command, it displays the startup window. After clicking on a button, I get:
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkObject’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_register_static: assertion ‘parent_type > 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkBuildable’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_interface_add_prerequisite: assertion ‘G_TYPE_IS_INTERFACE (interface_type)’ failed
(MATLAB:374189): GLib-CRITICAL **: 09:26:25.382: g_once_init_leave: assertion ‘result != 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.383: g_type_register_static: assertion ‘parent_type > 0’ failed
and then it freezes.
OS: Linux 3.10.0-957.el7.x86_64
Compiler: gcc 6.3.0
Glib: 2.42.2
Java: 1.8.0_211
Any ideas on what needs to be fixed? When I issue the spm command, it displays the startup window. After clicking on a button, I get:
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkObject’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_register_static: assertion ‘parent_type > 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-WARNING **: 09:26:25.382: cannot register existing type ‘GtkBuildable’
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_interface_add_prerequisite: assertion ‘G_TYPE_IS_INTERFACE (interface_type)’ failed
(MATLAB:374189): GLib-CRITICAL **: 09:26:25.382: g_once_init_leave: assertion ‘result != 0’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.382: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
(MATLAB:374189): GLib-GObject-CRITICAL **: 09:26:25.383: g_type_register_static: assertion ‘parent_type > 0’ failed
and then it freezes.
OS: Linux 3.10.0-957.el7.x86_64
Compiler: gcc 6.3.0
Glib: 2.42.2
Java: 1.8.0_211
Any ideas on what needs to be fixed? spm 12, r2019a, centos7 MATLAB Answers — New Questions
Unable to perform assignment because value of type ‘optim.problemdef.OptimizationExpression’ is not convertible to ‘double’.
Hello!
I’m working on an optimization problem where I need to manage the availability of multiple cores for task execution. My current approach involves finding the earliest available core and updating its availability after assigning a task. However, I’m encountering an issue when trying to update the hapsCoreAvailability array with the new start time and execution time.
the error is
Unable to perform assignment because value of type ‘optim.problemdef.OptimizationExpression’ is not convertible to
‘double’.
Error in Solve_Linear_Problem (line 355)
hapsCoreAvailability(coreIdx) = T_start + execTime;
Caused by:
Error using double
Conversion to double from optim.problemdef.OptimizationExpression is not possible.
here is the code
% Initialize the queue time matrix
Queue_time = optimexpr(N, numNodes, num_vehicles);
% Define variables
T_start = optimvar(‘T_start’, 1, ‘Type’, ‘continuous’, ‘LowerBound’, 0);
% Constraints
Queue_constraints1 = [];
Queue_constraints2 = [];
% Track availability of each HAPS core
hapsCoreAvailability = zeros(1, hapsCapacity);
nodeQueues = cell(numNodes, 1); % Queue times for each node
% Process tasks by generation time
for taskIdx = 1:num_vehicles
for subtaskIdx = 1:N
for nodeIdx = 1:numNodes
% Extract generation time, execution time, and uplink time
taskGenTime = generation_times_matrix(subtaskIdx, nodeIdx, taskIdx);
execTime = Execution_time(subtaskIdx, nodeIdx, taskIdx);
uplinkTime = uplink_time(subtaskIdx, nodeIdx, taskIdx);
% Calculate task arrival time considering uplink time
taskArrivalTime = taskGenTime + uplinkTime;
if nodeIdx == 4 % If assigned to HAPS
% Find the earliest available core
% [earliestCoreTime, coreIdx] = min(hapsCoreAvailability);
coreIdx = -1;
earliestCoreTime = inf;
% Iterate through each core’s availability time
for i = 1:length(hapsCoreAvailability)
% Check if the current core’s availability is earlier than the current earliest time
if hapsCoreAvailability(i) < earliestCoreTime
% Update earliest core time and index
earliestCoreTime = hapsCoreAvailability(i);
coreIdx = i;
end
end
% Start time is the maximum of arrival time and core availability
% T_start should be greater than or equal to both T_arrival and T_core
Queue_constraints1 = [Queue_constraints1, T_start >= taskArrivalTime];
Queue_constraints1 = [Queue_constraints1, T_start >= earliestCoreTime];
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update the core availability time
hapsCoreAvailability(coreIdx) = T_start + execTime; %% here is the error
else % For UAVs
% Queue tasks based on previous completion
if isempty(nodeQueues{nodeIdx})
startTime = taskArrivalTime;
else
T_queue = nodeQueues{nodeIdx}(end);
% T_start should be greater than or equal to both T_arrival and T_queue
Queue_constraints2 = [Queue_constraints2, T_start >= taskArrivalTime];
Queue_constraints2 = [Queue_constraints2, T_start >= T_queue];
end
% Calculate the queue time for the current subtask
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update departure time for the current subtask
departureTime = T_start + execTime;
nodeQueues{nodeIdx} = [nodeQueues{nodeIdx}, departureTime];
end
end
end
end
prob.Constraints.queue_time_constraints = Queue_constraints1;
prob.Constraints.queue_time_constraints = Queue_constraints2;
How can I correctly update the hapsCoreAvailability array with the new start time and execution time in the context of my optimization problem? Is there an alternative way to manage and update core availability when dealing with OptimizationExpression objects?
Any advice or suggestions would be greatly appreciated!
Thank you!Hello!
I’m working on an optimization problem where I need to manage the availability of multiple cores for task execution. My current approach involves finding the earliest available core and updating its availability after assigning a task. However, I’m encountering an issue when trying to update the hapsCoreAvailability array with the new start time and execution time.
the error is
Unable to perform assignment because value of type ‘optim.problemdef.OptimizationExpression’ is not convertible to
‘double’.
Error in Solve_Linear_Problem (line 355)
hapsCoreAvailability(coreIdx) = T_start + execTime;
Caused by:
Error using double
Conversion to double from optim.problemdef.OptimizationExpression is not possible.
here is the code
% Initialize the queue time matrix
Queue_time = optimexpr(N, numNodes, num_vehicles);
% Define variables
T_start = optimvar(‘T_start’, 1, ‘Type’, ‘continuous’, ‘LowerBound’, 0);
% Constraints
Queue_constraints1 = [];
Queue_constraints2 = [];
% Track availability of each HAPS core
hapsCoreAvailability = zeros(1, hapsCapacity);
nodeQueues = cell(numNodes, 1); % Queue times for each node
% Process tasks by generation time
for taskIdx = 1:num_vehicles
for subtaskIdx = 1:N
for nodeIdx = 1:numNodes
% Extract generation time, execution time, and uplink time
taskGenTime = generation_times_matrix(subtaskIdx, nodeIdx, taskIdx);
execTime = Execution_time(subtaskIdx, nodeIdx, taskIdx);
uplinkTime = uplink_time(subtaskIdx, nodeIdx, taskIdx);
% Calculate task arrival time considering uplink time
taskArrivalTime = taskGenTime + uplinkTime;
if nodeIdx == 4 % If assigned to HAPS
% Find the earliest available core
% [earliestCoreTime, coreIdx] = min(hapsCoreAvailability);
coreIdx = -1;
earliestCoreTime = inf;
% Iterate through each core’s availability time
for i = 1:length(hapsCoreAvailability)
% Check if the current core’s availability is earlier than the current earliest time
if hapsCoreAvailability(i) < earliestCoreTime
% Update earliest core time and index
earliestCoreTime = hapsCoreAvailability(i);
coreIdx = i;
end
end
% Start time is the maximum of arrival time and core availability
% T_start should be greater than or equal to both T_arrival and T_core
Queue_constraints1 = [Queue_constraints1, T_start >= taskArrivalTime];
Queue_constraints1 = [Queue_constraints1, T_start >= earliestCoreTime];
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update the core availability time
hapsCoreAvailability(coreIdx) = T_start + execTime; %% here is the error
else % For UAVs
% Queue tasks based on previous completion
if isempty(nodeQueues{nodeIdx})
startTime = taskArrivalTime;
else
T_queue = nodeQueues{nodeIdx}(end);
% T_start should be greater than or equal to both T_arrival and T_queue
Queue_constraints2 = [Queue_constraints2, T_start >= taskArrivalTime];
Queue_constraints2 = [Queue_constraints2, T_start >= T_queue];
end
% Calculate the queue time for the current subtask
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update departure time for the current subtask
departureTime = T_start + execTime;
nodeQueues{nodeIdx} = [nodeQueues{nodeIdx}, departureTime];
end
end
end
end
prob.Constraints.queue_time_constraints = Queue_constraints1;
prob.Constraints.queue_time_constraints = Queue_constraints2;
How can I correctly update the hapsCoreAvailability array with the new start time and execution time in the context of my optimization problem? Is there an alternative way to manage and update core availability when dealing with OptimizationExpression objects?
Any advice or suggestions would be greatly appreciated!
Thank you! Hello!
I’m working on an optimization problem where I need to manage the availability of multiple cores for task execution. My current approach involves finding the earliest available core and updating its availability after assigning a task. However, I’m encountering an issue when trying to update the hapsCoreAvailability array with the new start time and execution time.
the error is
Unable to perform assignment because value of type ‘optim.problemdef.OptimizationExpression’ is not convertible to
‘double’.
Error in Solve_Linear_Problem (line 355)
hapsCoreAvailability(coreIdx) = T_start + execTime;
Caused by:
Error using double
Conversion to double from optim.problemdef.OptimizationExpression is not possible.
here is the code
% Initialize the queue time matrix
Queue_time = optimexpr(N, numNodes, num_vehicles);
% Define variables
T_start = optimvar(‘T_start’, 1, ‘Type’, ‘continuous’, ‘LowerBound’, 0);
% Constraints
Queue_constraints1 = [];
Queue_constraints2 = [];
% Track availability of each HAPS core
hapsCoreAvailability = zeros(1, hapsCapacity);
nodeQueues = cell(numNodes, 1); % Queue times for each node
% Process tasks by generation time
for taskIdx = 1:num_vehicles
for subtaskIdx = 1:N
for nodeIdx = 1:numNodes
% Extract generation time, execution time, and uplink time
taskGenTime = generation_times_matrix(subtaskIdx, nodeIdx, taskIdx);
execTime = Execution_time(subtaskIdx, nodeIdx, taskIdx);
uplinkTime = uplink_time(subtaskIdx, nodeIdx, taskIdx);
% Calculate task arrival time considering uplink time
taskArrivalTime = taskGenTime + uplinkTime;
if nodeIdx == 4 % If assigned to HAPS
% Find the earliest available core
% [earliestCoreTime, coreIdx] = min(hapsCoreAvailability);
coreIdx = -1;
earliestCoreTime = inf;
% Iterate through each core’s availability time
for i = 1:length(hapsCoreAvailability)
% Check if the current core’s availability is earlier than the current earliest time
if hapsCoreAvailability(i) < earliestCoreTime
% Update earliest core time and index
earliestCoreTime = hapsCoreAvailability(i);
coreIdx = i;
end
end
% Start time is the maximum of arrival time and core availability
% T_start should be greater than or equal to both T_arrival and T_core
Queue_constraints1 = [Queue_constraints1, T_start >= taskArrivalTime];
Queue_constraints1 = [Queue_constraints1, T_start >= earliestCoreTime];
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update the core availability time
hapsCoreAvailability(coreIdx) = T_start + execTime; %% here is the error
else % For UAVs
% Queue tasks based on previous completion
if isempty(nodeQueues{nodeIdx})
startTime = taskArrivalTime;
else
T_queue = nodeQueues{nodeIdx}(end);
% T_start should be greater than or equal to both T_arrival and T_queue
Queue_constraints2 = [Queue_constraints2, T_start >= taskArrivalTime];
Queue_constraints2 = [Queue_constraints2, T_start >= T_queue];
end
% Calculate the queue time for the current subtask
Queue_time(subtaskIdx, nodeIdx, taskIdx) = T_start – taskArrivalTime;
% Update departure time for the current subtask
departureTime = T_start + execTime;
nodeQueues{nodeIdx} = [nodeQueues{nodeIdx}, departureTime];
end
end
end
end
prob.Constraints.queue_time_constraints = Queue_constraints1;
prob.Constraints.queue_time_constraints = Queue_constraints2;
How can I correctly update the hapsCoreAvailability array with the new start time and execution time in the context of my optimization problem? Is there an alternative way to manage and update core availability when dealing with OptimizationExpression objects?
Any advice or suggestions would be greatly appreciated!
Thank you! optimization, multiple cores, parallel processing MATLAB Answers — New Questions
trainNetwork reports too many input arguments in 2024a
Transfer learning code, based on the help example, that runs in 2023b, fails in 2024a
Error using trainNetwork (line 191)
Too many input arguments.
What has changed in the 2024a version? I see that trainnet is now recommended and I can do that going forward, but I would expect old code still to run.Transfer learning code, based on the help example, that runs in 2023b, fails in 2024a
Error using trainNetwork (line 191)
Too many input arguments.
What has changed in the 2024a version? I see that trainnet is now recommended and I can do that going forward, but I would expect old code still to run. Transfer learning code, based on the help example, that runs in 2023b, fails in 2024a
Error using trainNetwork (line 191)
Too many input arguments.
What has changed in the 2024a version? I see that trainnet is now recommended and I can do that going forward, but I would expect old code still to run. trainnetwork MATLAB Answers — New Questions
I want to start a youtube channel where i develop flight control algorithms. Which matlab license do i need?
As per title. What license do I need to use MatLab for youtube videos? What happens if I make money (in the longterm) from those videos?As per title. What license do I need to use MatLab for youtube videos? What happens if I make money (in the longterm) from those videos? As per title. What license do I need to use MatLab for youtube videos? What happens if I make money (in the longterm) from those videos? matlab, simulink, license MATLAB Answers — New Questions
how to change the direction of this code from right falling into left to left falling into right
Post Content Post Content homework, graph MATLAB Answers — New Questions
array mask not being reset in application
In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes)In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes) In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes) application designer, mask MATLAB Answers — New Questions
How do I install and configure the network license manager for Polyspace products?
I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so?I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so? I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so? MATLAB Answers — New Questions