Using fmincon to optimize Simulink model for optimal trajectory
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, so i want to search for optimal trajectory (by defining spline) position input to the Simulink Simscape Multibody model to minimize the total force input to the model. However, I encountered the following error in constraint function.
Error using chckxy
The first and second inputs must be of type double or single.
Error in spline (line 72)
[x,y,sizey,endslopes] = chckxy(x,y);
Error in GetStartedWithProblemBasedOptimizeLiveEditorTaskExample>constraintFcn (line 43)
dataStructure.signals(1).values=spline(nTime,locX,dataStructure.time);
Besides form that, when I try to exclude the constraint, the solution of the optimal trajectory is always the same with the initial points. Can anyone help me with the situation? Hereby I attach the folder.
0 comentarios
Respuestas (1)
Nipun
el 30 de Mayo de 2024
Hi Joshua,
I understand that you want help with calculating how many hours of data fall within the current hour in MATLAB. Here is a concise approach to solve this:
% Sample data: timestamps as datetime array
timestamps = datetime(2024, 5, 30, randi([0, 23], [100, 1]), randi([0, 59], [100, 1]), randi([0, 59], [100, 1]));
% Current hour
currentHour = hour(datetime('now'));
% Extract hours from timestamps
dataHours = hour(timestamps);
% Count occurrences within the current hour
hoursInCurrentHour = sum(dataHours == currentHour);
disp(hoursInCurrentHour);
Replace timestamps with your actual data.
Hope this helps.
Regards,
Nipun
0 comentarios
Ver también
Categorías
Más información sobre Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!