Category: Matlab
Category Archives: Matlab
Capabilities of mass action kinetics
Hi,
I have a molecule A. Molecule A can undergo a system of reactions as seen in the figure below.
Basically it can undergo a network of reactions (a custom combination of parallel and consequetive reversible steps ending with a final irreversible step). I have the rate constants (both forward and reverse for reversible steps) for all these steps.
Tilll now, i have been manually coding the time evolution of systems like these, using a system of first order coupled linear differential equations (solving a master equation). But the networks are getting complicated.
Solving this would get easier if I could use a MATLAB app which would help me build a network without manually coding it in.
Recently I came across this "Mass Action Kinetics" module in matlab. Does this module have the capability to solve systems like this? Is there anything else MATLAB has that can help me.
Thanks!Hi,
I have a molecule A. Molecule A can undergo a system of reactions as seen in the figure below.
Basically it can undergo a network of reactions (a custom combination of parallel and consequetive reversible steps ending with a final irreversible step). I have the rate constants (both forward and reverse for reversible steps) for all these steps.
Tilll now, i have been manually coding the time evolution of systems like these, using a system of first order coupled linear differential equations (solving a master equation). But the networks are getting complicated.
Solving this would get easier if I could use a MATLAB app which would help me build a network without manually coding it in.
Recently I came across this "Mass Action Kinetics" module in matlab. Does this module have the capability to solve systems like this? Is there anything else MATLAB has that can help me.
Thanks! Hi,
I have a molecule A. Molecule A can undergo a system of reactions as seen in the figure below.
Basically it can undergo a network of reactions (a custom combination of parallel and consequetive reversible steps ending with a final irreversible step). I have the rate constants (both forward and reverse for reversible steps) for all these steps.
Tilll now, i have been manually coding the time evolution of systems like these, using a system of first order coupled linear differential equations (solving a master equation). But the networks are getting complicated.
Solving this would get easier if I could use a MATLAB app which would help me build a network without manually coding it in.
Recently I came across this "Mass Action Kinetics" module in matlab. Does this module have the capability to solve systems like this? Is there anything else MATLAB has that can help me.
Thanks! differential equations, matrix manipulation, kinetics MATLAB Answers — New Questions
Generate n random numbers between 0.1 and 0.9 without repetition
Hi all,
I need to generate random points where and , excluding the point . My attempt is the following:
%define the lower limit
lower_limit = 0.1;
%define the upper limit
higher_limit = 0.9;
%No of random points
No_pts = 20;
%excluding value
No_value = 0.5
%Generate
valid_vals = setdiff(lower_limit:higher_limit, No_value);
result = valid_vals( randi(length(valid_vals), No_pts, 2) );
When running this code I only get one value which is . Any idea how this can be modified to work properly?
Thanks.Hi all,
I need to generate random points where and , excluding the point . My attempt is the following:
%define the lower limit
lower_limit = 0.1;
%define the upper limit
higher_limit = 0.9;
%No of random points
No_pts = 20;
%excluding value
No_value = 0.5
%Generate
valid_vals = setdiff(lower_limit:higher_limit, No_value);
result = valid_vals( randi(length(valid_vals), No_pts, 2) );
When running this code I only get one value which is . Any idea how this can be modified to work properly?
Thanks. Hi all,
I need to generate random points where and , excluding the point . My attempt is the following:
%define the lower limit
lower_limit = 0.1;
%define the upper limit
higher_limit = 0.9;
%No of random points
No_pts = 20;
%excluding value
No_value = 0.5
%Generate
valid_vals = setdiff(lower_limit:higher_limit, No_value);
result = valid_vals( randi(length(valid_vals), No_pts, 2) );
When running this code I only get one value which is . Any idea how this can be modified to work properly?
Thanks. random, points, vectors, matlab MATLAB Answers — New Questions
Editing an Aircraft Actor in Simulink-Unreal Simulation
Hello,
As part of my project, I am simulating an aircraft using Simulink, and I have set up a Simulink system to communicate with Unreal Engine (as shown in the attached image). The issue I’m facing is that when I open the Unreal project AutoVrtlEnv, which is ported from MATLAB to Unreal, I can edit the airport scene but not the aircraft itself. The aircraft is an actor class that is dynamically spawned in Unreal via the Simulation 3D Aircraft Block.
The problem is that this aircraft actor (as shown in the attached image) does not exist when the simulation is not running—it only appears once the simulation starts. While I can technically edit these dynamically spawned actors by pausing the simulation, any changes I make are lost when the simulation restarts, as the actors are recreated from scratch.
I need to modify the Sim3dMainCamera under the Sim3dMWAirliner actor class. Is there a way to modify or duplicate it so that I can edit it as a separate class without losing my changes?
Any guidance would be greatly appreciated!Hello,
As part of my project, I am simulating an aircraft using Simulink, and I have set up a Simulink system to communicate with Unreal Engine (as shown in the attached image). The issue I’m facing is that when I open the Unreal project AutoVrtlEnv, which is ported from MATLAB to Unreal, I can edit the airport scene but not the aircraft itself. The aircraft is an actor class that is dynamically spawned in Unreal via the Simulation 3D Aircraft Block.
The problem is that this aircraft actor (as shown in the attached image) does not exist when the simulation is not running—it only appears once the simulation starts. While I can technically edit these dynamically spawned actors by pausing the simulation, any changes I make are lost when the simulation restarts, as the actors are recreated from scratch.
I need to modify the Sim3dMainCamera under the Sim3dMWAirliner actor class. Is there a way to modify or duplicate it so that I can edit it as a separate class without losing my changes?
Any guidance would be greatly appreciated! Hello,
As part of my project, I am simulating an aircraft using Simulink, and I have set up a Simulink system to communicate with Unreal Engine (as shown in the attached image). The issue I’m facing is that when I open the Unreal project AutoVrtlEnv, which is ported from MATLAB to Unreal, I can edit the airport scene but not the aircraft itself. The aircraft is an actor class that is dynamically spawned in Unreal via the Simulation 3D Aircraft Block.
The problem is that this aircraft actor (as shown in the attached image) does not exist when the simulation is not running—it only appears once the simulation starts. While I can technically edit these dynamically spawned actors by pausing the simulation, any changes I make are lost when the simulation restarts, as the actors are recreated from scratch.
I need to modify the Sim3dMainCamera under the Sim3dMWAirliner actor class. Is there a way to modify or duplicate it so that I can edit it as a separate class without losing my changes?
Any guidance would be greatly appreciated! simulink, simulation, unreal engine MATLAB Answers — New Questions
Remove outliers but be careful with end points
Hi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
ThanksHi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
Thanks Hi, I have some typcial data like this that I want to remove the outliers (red arrows)
I use the rmoutliers function and then fillmissing to handle these.
%For last plotted Data
ax=app.UIAxes3;
[datax,datay] = getDataFromGraph(app,ax,1); % my fucntion that gets the last plot x and y values.
A=[datax datay];
[B,TFrm,TFoutlier] = rmoutliers(A,"movmedian",10);
x=B(:,1); y=B(:,2); hold(ax,"on");
The contraint I have is if I remove an outlier from the 1st or last data point (i.e. green arrow above), then it MUST be replaced with e.g the nearest non outlier.
So I thought this would do it:
F = fillmissing(y,’linear’,’EndValues’,’nearest’); %F = fillmissing(y,’movmedian’,10);
plot(ax,x,F,’.-‘);
However, its ignoring the last point (I dont mind other outliers being ignored, I just need the starting x and finishing x to be the same as the original data
Thanks rmoutliers, fillmissing MATLAB Answers — New Questions
closed countour around a given point
Hi and I’d like to say thanks in advance.
I am processing some gridded data using contour/countourc commands and I am trying to do 3 things.
find all the closed countours that are centered and suround a given x,y cordinate
find the outermost closed countour from the above list
find the maximum, min and average distance of the above outermost contour from the center x,y cordinate (countours are not always circular and may be of irregular shape in my data).
I started with a sample data (from matlab called peaks) to build my code and impliment on my actual data but I am still stuck on 1 and 2.
(image attaced) I want my code to detect contour levels 18, 16, 14, 12 which are closed and surrounding my center point (blue dot) but instead it is picking 8, 10, 14, 16, 18. How can i modify the code to only detect the prefered contour levels (18,16,14,12) from which i can find the outermost contour and the 3 distances from the center. Note, level 18 is behind the center dot. Also attached countour z data… just incase
%___________________________________________________________________________
% Specify the center point and search radius
centerPoint = [25, 37.5];
searchRadius = 20;
% get and plot contour data
Z = peaks+10; % make colorbar positive. using built in sample data from matlab (peaks)
[M,h] = contour(Z);
clabel(M, h);
colorbar
% plot centerPoint
hold on
scatter(25, 37.5,"filled")
hold off
% crop portion of search area for easy visual
xlim([25 – searchRadius 25 + searchRadius])
ylim([37.5 – searchRadius 37.5 + searchRadius])
%___________________________________________________________________________
% Calculate contours
contourData = contourc(Z);
% Parse contour data
idx = 1;
while idx < size(contourData, 2)
contourLevel = contourData(1, idx); % Contour level
numPoints = contourData(2, idx); % Number of points in the contour
contourPoints = contourData(:, idx+1:idx+numPoints); % Contour points (x, y coordinates)
% Check if contour is closed (first and last points are the same)
isClosed = isequal(contourPoints(:,1), contourPoints(:,end));
% Check if contour surrounds the specified point
if isClosed
% Calculate distance of contour points to center point
distToCenter = sqrt((contourPoints(1, 🙂 – centerPoint(1)).^2 + (contourPoints(2, 🙂 – centerPoint(2)).^2);
% Check if all points are within search radius
if all(distToCenter <= searchRadius)
disp([‘Contour Level: ‘, num2str(contourLevel)]);
disp([‘Contour is closed and surrounds point (‘, num2str(centerPoint(1)), ‘, ‘, num2str(centerPoint(2)), ‘)’]);
disp(‘Contour Points:’);
%disp(contourPoints);
disp(‘———————————————‘);
end
end
% Move to the next contour
idx = idx + numPoints + 1;
end
clear Z M h contourData contourLevel numPoints contourPoints …
centerPoint searchRadius contourLevels isClosed distToCenter idx;Hi and I’d like to say thanks in advance.
I am processing some gridded data using contour/countourc commands and I am trying to do 3 things.
find all the closed countours that are centered and suround a given x,y cordinate
find the outermost closed countour from the above list
find the maximum, min and average distance of the above outermost contour from the center x,y cordinate (countours are not always circular and may be of irregular shape in my data).
I started with a sample data (from matlab called peaks) to build my code and impliment on my actual data but I am still stuck on 1 and 2.
(image attaced) I want my code to detect contour levels 18, 16, 14, 12 which are closed and surrounding my center point (blue dot) but instead it is picking 8, 10, 14, 16, 18. How can i modify the code to only detect the prefered contour levels (18,16,14,12) from which i can find the outermost contour and the 3 distances from the center. Note, level 18 is behind the center dot. Also attached countour z data… just incase
%___________________________________________________________________________
% Specify the center point and search radius
centerPoint = [25, 37.5];
searchRadius = 20;
% get and plot contour data
Z = peaks+10; % make colorbar positive. using built in sample data from matlab (peaks)
[M,h] = contour(Z);
clabel(M, h);
colorbar
% plot centerPoint
hold on
scatter(25, 37.5,"filled")
hold off
% crop portion of search area for easy visual
xlim([25 – searchRadius 25 + searchRadius])
ylim([37.5 – searchRadius 37.5 + searchRadius])
%___________________________________________________________________________
% Calculate contours
contourData = contourc(Z);
% Parse contour data
idx = 1;
while idx < size(contourData, 2)
contourLevel = contourData(1, idx); % Contour level
numPoints = contourData(2, idx); % Number of points in the contour
contourPoints = contourData(:, idx+1:idx+numPoints); % Contour points (x, y coordinates)
% Check if contour is closed (first and last points are the same)
isClosed = isequal(contourPoints(:,1), contourPoints(:,end));
% Check if contour surrounds the specified point
if isClosed
% Calculate distance of contour points to center point
distToCenter = sqrt((contourPoints(1, 🙂 – centerPoint(1)).^2 + (contourPoints(2, 🙂 – centerPoint(2)).^2);
% Check if all points are within search radius
if all(distToCenter <= searchRadius)
disp([‘Contour Level: ‘, num2str(contourLevel)]);
disp([‘Contour is closed and surrounds point (‘, num2str(centerPoint(1)), ‘, ‘, num2str(centerPoint(2)), ‘)’]);
disp(‘Contour Points:’);
%disp(contourPoints);
disp(‘———————————————‘);
end
end
% Move to the next contour
idx = idx + numPoints + 1;
end
clear Z M h contourData contourLevel numPoints contourPoints …
centerPoint searchRadius contourLevels isClosed distToCenter idx; Hi and I’d like to say thanks in advance.
I am processing some gridded data using contour/countourc commands and I am trying to do 3 things.
find all the closed countours that are centered and suround a given x,y cordinate
find the outermost closed countour from the above list
find the maximum, min and average distance of the above outermost contour from the center x,y cordinate (countours are not always circular and may be of irregular shape in my data).
I started with a sample data (from matlab called peaks) to build my code and impliment on my actual data but I am still stuck on 1 and 2.
(image attaced) I want my code to detect contour levels 18, 16, 14, 12 which are closed and surrounding my center point (blue dot) but instead it is picking 8, 10, 14, 16, 18. How can i modify the code to only detect the prefered contour levels (18,16,14,12) from which i can find the outermost contour and the 3 distances from the center. Note, level 18 is behind the center dot. Also attached countour z data… just incase
%___________________________________________________________________________
% Specify the center point and search radius
centerPoint = [25, 37.5];
searchRadius = 20;
% get and plot contour data
Z = peaks+10; % make colorbar positive. using built in sample data from matlab (peaks)
[M,h] = contour(Z);
clabel(M, h);
colorbar
% plot centerPoint
hold on
scatter(25, 37.5,"filled")
hold off
% crop portion of search area for easy visual
xlim([25 – searchRadius 25 + searchRadius])
ylim([37.5 – searchRadius 37.5 + searchRadius])
%___________________________________________________________________________
% Calculate contours
contourData = contourc(Z);
% Parse contour data
idx = 1;
while idx < size(contourData, 2)
contourLevel = contourData(1, idx); % Contour level
numPoints = contourData(2, idx); % Number of points in the contour
contourPoints = contourData(:, idx+1:idx+numPoints); % Contour points (x, y coordinates)
% Check if contour is closed (first and last points are the same)
isClosed = isequal(contourPoints(:,1), contourPoints(:,end));
% Check if contour surrounds the specified point
if isClosed
% Calculate distance of contour points to center point
distToCenter = sqrt((contourPoints(1, 🙂 – centerPoint(1)).^2 + (contourPoints(2, 🙂 – centerPoint(2)).^2);
% Check if all points are within search radius
if all(distToCenter <= searchRadius)
disp([‘Contour Level: ‘, num2str(contourLevel)]);
disp([‘Contour is closed and surrounds point (‘, num2str(centerPoint(1)), ‘, ‘, num2str(centerPoint(2)), ‘)’]);
disp(‘Contour Points:’);
%disp(contourPoints);
disp(‘———————————————‘);
end
end
% Move to the next contour
idx = idx + numPoints + 1;
end
clear Z M h contourData contourLevel numPoints contourPoints …
centerPoint searchRadius contourLevels isClosed distToCenter idx; contour MATLAB Answers — New Questions
How to expand a matrix and interpolate between values?
I have a .mat file that is a 3×2 array. The first column contains hourly data but I would like it to be seconds and interpolate the values in between.
An example would be:
Any help is very much appreciated.I have a .mat file that is a 3×2 array. The first column contains hourly data but I would like it to be seconds and interpolate the values in between.
An example would be:
Any help is very much appreciated. I have a .mat file that is a 3×2 array. The first column contains hourly data but I would like it to be seconds and interpolate the values in between.
An example would be:
Any help is very much appreciated. table, time, interpolation MATLAB Answers — New Questions
ros2bagreader unable to parse “metadata.yaml”
Hello, I am trying to open a mcap ros2 bag and I receive the following error:
Error using ros2bagreader (line 478)
Unable to parse "metadata.yaml" file in the specified folder path. Ensure that the YAML file is correctly formatted.
I am using matlab 2024b version.
Any advice on how to solve this issue?
Thank you,
AnnalisaHello, I am trying to open a mcap ros2 bag and I receive the following error:
Error using ros2bagreader (line 478)
Unable to parse "metadata.yaml" file in the specified folder path. Ensure that the YAML file is correctly formatted.
I am using matlab 2024b version.
Any advice on how to solve this issue?
Thank you,
Annalisa Hello, I am trying to open a mcap ros2 bag and I receive the following error:
Error using ros2bagreader (line 478)
Unable to parse "metadata.yaml" file in the specified folder path. Ensure that the YAML file is correctly formatted.
I am using matlab 2024b version.
Any advice on how to solve this issue?
Thank you,
Annalisa ros2bagreader metadata.yaml MATLAB Answers — New Questions
Help me get this shape on the masks
I have some masks and i want to create a shape like a freeform donut that will enclose the masks,
I have drawn by red and green of what i want.I have some masks and i want to create a shape like a freeform donut that will enclose the masks,
I have drawn by red and green of what i want. I have some masks and i want to create a shape like a freeform donut that will enclose the masks,
I have drawn by red and green of what i want. image processing, image segmentation, digital image processing, computer vision MATLAB Answers — New Questions
How to read the X,Y and Z coordinates from a TIFF image extracted into Matlab?
I have extracted a TIFF image into Matlab using the geotiff function [A, R] = geotiffread(filename). Now the image is stored for example in A. I want to extract the X,Y and Z coordinates from this image and plot it later using surf function. How do I achieve this?
Thanks for any inputs or pointersI have extracted a TIFF image into Matlab using the geotiff function [A, R] = geotiffread(filename). Now the image is stored for example in A. I want to extract the X,Y and Z coordinates from this image and plot it later using surf function. How do I achieve this?
Thanks for any inputs or pointers I have extracted a TIFF image into Matlab using the geotiff function [A, R] = geotiffread(filename). Now the image is stored for example in A. I want to extract the X,Y and Z coordinates from this image and plot it later using surf function. How do I achieve this?
Thanks for any inputs or pointers tiff image, xyz coordinates, surf function MATLAB Answers — New Questions
python method from matlab object
Here is the problem I have,
I have a python class, which contain properties that are memebers of specific class, typically to rotate a motor.
The class is defined as below, it uses the pytrinamic for the PD42-1370 motors: https://github.com/analogdevicesinc/PyTrinamic
I have made a wrapper class of the example provided for the Pytrinamic: https://github.com/analogdevicesinc/PyTrinamic/blob/master/examples/modules/TMCM1370/TMCL/rotate_demo.py
"""
pd42_1370.py wrapper to connect to the PD42-X-1370 stepper motor
"""
import pytrinamic
from pytrinamic.connections import ConnectionManager
from pytrinamic.connections import UsbTmclInterface
from pytrinamic.modules import TMCM1370
class PD42_1370():
def __init__(self,com_port,baudrate):
self.com_port = com_port
self.baudrate = baudrate
options = "–interface serial_tmcl –port "+ str(self.com_port)+ " –data_rate "+str(self.baudrate)
self.connection_manager = ConnectionManager(options)
self.interface = self.connection_manager.connect()
print("connected")
self.module = TMCM1370(self.interface)
print("module added")
self.motor = self.module.motors[0]
def disconnect(self):
self.connection_manager.disconnect()
print("disconnected")
def rotateRight(self,speed):
self.motor.rotate(speed)
my MATLAB code is:
py.importlib.import_module(‘pd42_1370’)
ax = py.pd42_1370.PD42_1370(‘COM5’,9600)
ax.rotateRight(int32(10000000))
ax.disconnect()
It is working really fine. But instead of sending the command:
ax.rotateRight(int32(10000000))
I would like to write it:
ax.motor.rotate(int32(100000000))
this later throw back an error:
Unrecognized method, property, or field ‘rotate’ for class ‘py.pytrinamic.modules.TMCM1370._MotorTypeA’.
I cannot figure out what is wrong.
If this could be sorted, then it would help by using direct calls to python, rather than keeping developping the wrapper.Here is the problem I have,
I have a python class, which contain properties that are memebers of specific class, typically to rotate a motor.
The class is defined as below, it uses the pytrinamic for the PD42-1370 motors: https://github.com/analogdevicesinc/PyTrinamic
I have made a wrapper class of the example provided for the Pytrinamic: https://github.com/analogdevicesinc/PyTrinamic/blob/master/examples/modules/TMCM1370/TMCL/rotate_demo.py
"""
pd42_1370.py wrapper to connect to the PD42-X-1370 stepper motor
"""
import pytrinamic
from pytrinamic.connections import ConnectionManager
from pytrinamic.connections import UsbTmclInterface
from pytrinamic.modules import TMCM1370
class PD42_1370():
def __init__(self,com_port,baudrate):
self.com_port = com_port
self.baudrate = baudrate
options = "–interface serial_tmcl –port "+ str(self.com_port)+ " –data_rate "+str(self.baudrate)
self.connection_manager = ConnectionManager(options)
self.interface = self.connection_manager.connect()
print("connected")
self.module = TMCM1370(self.interface)
print("module added")
self.motor = self.module.motors[0]
def disconnect(self):
self.connection_manager.disconnect()
print("disconnected")
def rotateRight(self,speed):
self.motor.rotate(speed)
my MATLAB code is:
py.importlib.import_module(‘pd42_1370’)
ax = py.pd42_1370.PD42_1370(‘COM5’,9600)
ax.rotateRight(int32(10000000))
ax.disconnect()
It is working really fine. But instead of sending the command:
ax.rotateRight(int32(10000000))
I would like to write it:
ax.motor.rotate(int32(100000000))
this later throw back an error:
Unrecognized method, property, or field ‘rotate’ for class ‘py.pytrinamic.modules.TMCM1370._MotorTypeA’.
I cannot figure out what is wrong.
If this could be sorted, then it would help by using direct calls to python, rather than keeping developping the wrapper. Here is the problem I have,
I have a python class, which contain properties that are memebers of specific class, typically to rotate a motor.
The class is defined as below, it uses the pytrinamic for the PD42-1370 motors: https://github.com/analogdevicesinc/PyTrinamic
I have made a wrapper class of the example provided for the Pytrinamic: https://github.com/analogdevicesinc/PyTrinamic/blob/master/examples/modules/TMCM1370/TMCL/rotate_demo.py
"""
pd42_1370.py wrapper to connect to the PD42-X-1370 stepper motor
"""
import pytrinamic
from pytrinamic.connections import ConnectionManager
from pytrinamic.connections import UsbTmclInterface
from pytrinamic.modules import TMCM1370
class PD42_1370():
def __init__(self,com_port,baudrate):
self.com_port = com_port
self.baudrate = baudrate
options = "–interface serial_tmcl –port "+ str(self.com_port)+ " –data_rate "+str(self.baudrate)
self.connection_manager = ConnectionManager(options)
self.interface = self.connection_manager.connect()
print("connected")
self.module = TMCM1370(self.interface)
print("module added")
self.motor = self.module.motors[0]
def disconnect(self):
self.connection_manager.disconnect()
print("disconnected")
def rotateRight(self,speed):
self.motor.rotate(speed)
my MATLAB code is:
py.importlib.import_module(‘pd42_1370’)
ax = py.pd42_1370.PD42_1370(‘COM5’,9600)
ax.rotateRight(int32(10000000))
ax.disconnect()
It is working really fine. But instead of sending the command:
ax.rotateRight(int32(10000000))
I would like to write it:
ax.motor.rotate(int32(100000000))
this later throw back an error:
Unrecognized method, property, or field ‘rotate’ for class ‘py.pytrinamic.modules.TMCM1370._MotorTypeA’.
I cannot figure out what is wrong.
If this could be sorted, then it would help by using direct calls to python, rather than keeping developping the wrapper. python, trinamic, class MATLAB Answers — New Questions
Why am I unable to execute my standalone application with an error referring to “mclmcrrt9_4.dll”
Dear support,
I have an application which shows following message at launch: "Could not find version 9.4 of the MATLAB Runtime. Attempting to load mclmcrrt9_4.dll. Please install the correct version of MATLAB Runtime".
I went on that page MATLAB Runtime – MATLAB Compiler – MATLAB to find the version I need.
When lauching the exe file which I get from download, I see a small window indicating that some file extraction is being processed, then that window closes, and it seems nothing has happened. Nowwhere do I find any "v94" folder which I expect to have after all extraction is done. Could you support with this issue ?
Thanks so much.Dear support,
I have an application which shows following message at launch: "Could not find version 9.4 of the MATLAB Runtime. Attempting to load mclmcrrt9_4.dll. Please install the correct version of MATLAB Runtime".
I went on that page MATLAB Runtime – MATLAB Compiler – MATLAB to find the version I need.
When lauching the exe file which I get from download, I see a small window indicating that some file extraction is being processed, then that window closes, and it seems nothing has happened. Nowwhere do I find any "v94" folder which I expect to have after all extraction is done. Could you support with this issue ?
Thanks so much. Dear support,
I have an application which shows following message at launch: "Could not find version 9.4 of the MATLAB Runtime. Attempting to load mclmcrrt9_4.dll. Please install the correct version of MATLAB Runtime".
I went on that page MATLAB Runtime – MATLAB Compiler – MATLAB to find the version I need.
When lauching the exe file which I get from download, I see a small window indicating that some file extraction is being processed, then that window closes, and it seems nothing has happened. Nowwhere do I find any "v94" folder which I expect to have after all extraction is done. Could you support with this issue ?
Thanks so much. runtime matlab download MATLAB Answers — New Questions
Find the range of duplicates in a sorted element
So let’s say I have a vector
a = [6 2 2 5]
I sort it with the function and now:
a = [2 2 5 6]
How do I find the range of the duplicate number(2)? Like, I want it to tell me the start of the duplicte(element1) and the end of the duplicates(element2)
An if I have [2 2 5 5 6]
It tells me copies are in 1-2 and 3-5So let’s say I have a vector
a = [6 2 2 5]
I sort it with the function and now:
a = [2 2 5 6]
How do I find the range of the duplicate number(2)? Like, I want it to tell me the start of the duplicte(element1) and the end of the duplicates(element2)
An if I have [2 2 5 5 6]
It tells me copies are in 1-2 and 3-5 So let’s say I have a vector
a = [6 2 2 5]
I sort it with the function and now:
a = [2 2 5 6]
How do I find the range of the duplicate number(2)? Like, I want it to tell me the start of the duplicte(element1) and the end of the duplicates(element2)
An if I have [2 2 5 5 6]
It tells me copies are in 1-2 and 3-5 sort, vector MATLAB Answers — New Questions
When I try to open MATLAB, only a file named matlab_crash_dump.11828 is created and MATLAB does not open.
When I try to open MATLAB, only a file named matlab_crash_dump.11828 is created and MATLAB does not open. I have a license. How can I open MATLAB?
The matlab_crash_dump.11828 file is provided in the attached zip file.
Thank you.When I try to open MATLAB, only a file named matlab_crash_dump.11828 is created and MATLAB does not open. I have a license. How can I open MATLAB?
The matlab_crash_dump.11828 file is provided in the attached zip file.
Thank you. When I try to open MATLAB, only a file named matlab_crash_dump.11828 is created and MATLAB does not open. I have a license. How can I open MATLAB?
The matlab_crash_dump.11828 file is provided in the attached zip file.
Thank you. matlab, matlab_crash_dump, 11828 MATLAB Answers — New Questions
Possibility to Restore deleted requirement
Hi.
Using Simulink Requirements from the Requirements Error, I deleted a requirement and I was trying to restore it.
Is there any Undo or Restore command or a workaround to solve the problem?
Thanks.Hi.
Using Simulink Requirements from the Requirements Error, I deleted a requirement and I was trying to restore it.
Is there any Undo or Restore command or a workaround to solve the problem?
Thanks. Hi.
Using Simulink Requirements from the Requirements Error, I deleted a requirement and I was trying to restore it.
Is there any Undo or Restore command or a workaround to solve the problem?
Thanks. restore requirement, simulink MATLAB Answers — New Questions
Accessing workspace variables with parallel workers
I have a simulink model that I would like to run a number of times over a range of 2 different variables. In my simulink model I was using model callbacks to take the 2 random initial variables and calculate the initial conditions to some of my integrators but this wasn’t working and now I am doing this in the for loops. However when I run the simulation it throws an error saying "Warning: Error in the simulation was caused by missing variable ‘q_e2b0’. Set "TransferBaseWorkspaceVariables" option to "on" to fix the issue." I tried setting that in setModelParameters but that doesn’t work either.
Below is a pseduo code of my script:
num_sims = length(phi_range)*length(theta_range);
simIn(1:num_sims) = Simulink.SimulationInput(‘SixDOFSimulink’);
sim_itr = 1;
for i = 1:length(phi_range)
for j = 1:length(theta_range)
phi0 = phi_range(i);
theta0 = theta_range(j);
% do calculations %
pos0 = %value%
v_b0 = %value%
w0 = %value%
q_e2b_0 = %value%
simIn(sim_itr) = simIn(sim_itr).setModelParameter(‘SimulationMode’, ‘normal’, …
‘SaveTime’, ‘on’, …
‘SaveOutput’, ‘on’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘theta0’, theta0, ‘workspace’, ‘SixDOFSimulink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘phi0’, phi0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘q_e2b0’, q_e2b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘v_b0’, v_b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘pos0’, pos0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘w0’, w0, ‘workspace’, ‘SixDOFSimunlink’);
sim_itr = sim_itr+1;
end
end
out = parsim(simIn, ‘ShowProgress’, ‘on’);
delete(gcp(‘nocreate’))I have a simulink model that I would like to run a number of times over a range of 2 different variables. In my simulink model I was using model callbacks to take the 2 random initial variables and calculate the initial conditions to some of my integrators but this wasn’t working and now I am doing this in the for loops. However when I run the simulation it throws an error saying "Warning: Error in the simulation was caused by missing variable ‘q_e2b0’. Set "TransferBaseWorkspaceVariables" option to "on" to fix the issue." I tried setting that in setModelParameters but that doesn’t work either.
Below is a pseduo code of my script:
num_sims = length(phi_range)*length(theta_range);
simIn(1:num_sims) = Simulink.SimulationInput(‘SixDOFSimulink’);
sim_itr = 1;
for i = 1:length(phi_range)
for j = 1:length(theta_range)
phi0 = phi_range(i);
theta0 = theta_range(j);
% do calculations %
pos0 = %value%
v_b0 = %value%
w0 = %value%
q_e2b_0 = %value%
simIn(sim_itr) = simIn(sim_itr).setModelParameter(‘SimulationMode’, ‘normal’, …
‘SaveTime’, ‘on’, …
‘SaveOutput’, ‘on’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘theta0’, theta0, ‘workspace’, ‘SixDOFSimulink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘phi0’, phi0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘q_e2b0’, q_e2b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘v_b0’, v_b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘pos0’, pos0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘w0’, w0, ‘workspace’, ‘SixDOFSimunlink’);
sim_itr = sim_itr+1;
end
end
out = parsim(simIn, ‘ShowProgress’, ‘on’);
delete(gcp(‘nocreate’)) I have a simulink model that I would like to run a number of times over a range of 2 different variables. In my simulink model I was using model callbacks to take the 2 random initial variables and calculate the initial conditions to some of my integrators but this wasn’t working and now I am doing this in the for loops. However when I run the simulation it throws an error saying "Warning: Error in the simulation was caused by missing variable ‘q_e2b0’. Set "TransferBaseWorkspaceVariables" option to "on" to fix the issue." I tried setting that in setModelParameters but that doesn’t work either.
Below is a pseduo code of my script:
num_sims = length(phi_range)*length(theta_range);
simIn(1:num_sims) = Simulink.SimulationInput(‘SixDOFSimulink’);
sim_itr = 1;
for i = 1:length(phi_range)
for j = 1:length(theta_range)
phi0 = phi_range(i);
theta0 = theta_range(j);
% do calculations %
pos0 = %value%
v_b0 = %value%
w0 = %value%
q_e2b_0 = %value%
simIn(sim_itr) = simIn(sim_itr).setModelParameter(‘SimulationMode’, ‘normal’, …
‘SaveTime’, ‘on’, …
‘SaveOutput’, ‘on’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘theta0’, theta0, ‘workspace’, ‘SixDOFSimulink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘phi0’, phi0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘q_e2b0’, q_e2b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘v_b0’, v_b0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘pos0’, pos0, ‘workspace’, ‘SixDOFSimunlink’);
simIn(sim_itr) = simIn(sim_itr).setVariable(‘w0’, w0, ‘workspace’, ‘SixDOFSimunlink’);
sim_itr = sim_itr+1;
end
end
out = parsim(simIn, ‘ShowProgress’, ‘on’);
delete(gcp(‘nocreate’)) simulink, parallel computing toolbox MATLAB Answers — New Questions
I am having trouble getting the engine speed to 0 rpm when simulating a series hybrid vehicle controller.
Hi, I am having trouble controlling the motor block speed to 0 when the motor start signal is 0. It works fine when I give the motor speed 800rpm when the start signal is 0
However when I give the speed 0 rpm when the signal is 0, the result is that the motor speed decreases.
I have attached the simulink model and the driving cycle I built with this question. It’s built on matlab r2022a and based on the model in the following link: https://www.mathworks.com/help/sdl/ug/series-hybrid-transmission.html
If someone have any idea about a solution to my problem, I will be very grateful.
Thanks in advance to anybody that awnser to this post ! :)Hi, I am having trouble controlling the motor block speed to 0 when the motor start signal is 0. It works fine when I give the motor speed 800rpm when the start signal is 0
However when I give the speed 0 rpm when the signal is 0, the result is that the motor speed decreases.
I have attached the simulink model and the driving cycle I built with this question. It’s built on matlab r2022a and based on the model in the following link: https://www.mathworks.com/help/sdl/ug/series-hybrid-transmission.html
If someone have any idea about a solution to my problem, I will be very grateful.
Thanks in advance to anybody that awnser to this post ! 🙂 Hi, I am having trouble controlling the motor block speed to 0 when the motor start signal is 0. It works fine when I give the motor speed 800rpm when the start signal is 0
However when I give the speed 0 rpm when the signal is 0, the result is that the motor speed decreases.
I have attached the simulink model and the driving cycle I built with this question. It’s built on matlab r2022a and based on the model in the following link: https://www.mathworks.com/help/sdl/ug/series-hybrid-transmission.html
If someone have any idea about a solution to my problem, I will be very grateful.
Thanks in advance to anybody that awnser to this post ! 🙂 speed, control MATLAB Answers — New Questions
How to obtain the average diameter of a segment of a graph?
I have a graph structure that is formed after binarizing an image of blood vessels and obtaining the skeleton, then creating a graph structure. The graph looks like this:
K >> graph =
graph with properties:
Edges: [773×2 table]
Nodes: [773×0 table]
Which means I have 773 edges and each edge has 2 vertices. The graph edges look like this:
EndNodes Weight
__________ ______
1 2 1
1 53 1.4142
2 3 1
3 4 1
4 5 1
Now, at the end of the graph creation, I have other helper functions that help me create a diameters table with points that have been inferred on the binary image between the vessel walls. So, for each graph point the algorithm tries to look for walls and once found it saves the coordinates and other values in a table.
This is how the table gets created and how it looks like:
diam_tab = table();
for i = 1:n_line % for all the lines detected
row = cell(1,7);
row{1} = dt(i,:); % the diameter measured
row{2} = t; % the time dimension
row{3} = fs; % the frame sampling rate
row{4} = squeeze(permute(w1_t(i,:,:), [1, 3, 2])); % The value coordiantes of the first wall
row{5} = squeeze(permute(w2_t(i,:,:), [1, 3, 2])); % The value coordinates of the second wall
row{6} = line_type(i); % just a string, not relevant
row{7} = util.make_uuid(); % an UUID attached
diam_tab = [diam_tab; row];
end
And finally look like this:
y x fs z1 z2 type UUID
______________ ______________ ______ ________________ ________________ ________ ________________________________________
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘6ada1ae1-00f8-4d9b-aa7a-80c7be26aaa1’}
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘b8da617c-f55f-418c-88dc-5862c968a637’}
Now, what I want to do is, modify this table so that it doesn’t take all of the 773 rows but instead only like an average of the diameters over a certain segment of the graph. Let’s suppose say that the graph has a Y shape, I would like to obtain, every lets say 10 points an average diameter of that section.
Then, finally, the diam_tab table will not have 773 rows, but only the ones left after averaging over several sections of the graph, let’s say for a graph length of 100 the result would be 100 rows, but I want to get instead the average of the graph at sections of length for ex 10, which would leave me with 10 rows.
And finally, the diam_table would be updated to reflect these values, or at the very least replaced by a similar functioning table.
So far, this is what I turned up with in my code, which isn’t exactly working well as it seems to only get center points between two nodes and then breaks when I attach the created structure to the graph.
function diameters_table = segment_vessel_table(ts, diam_tab)
graph = ts.load_var(‘center_line’).graph;
[y, x] = find(ts.load_var(‘binary_image’));
node_coordinates = [x, y];
n_vessels = height(diam_tab);
midpoints = zeros(n_vessels, 2);
n_samples_graph = 5;
for i = 1:n_vessels
z1 = diam_tab.z1{i};
z2 = diam_tab.z2{i};
mids = (z1 + z2) / 2;
midpoints(i, 🙂 = mean(mids, 2);
end
idx = round(linspace(1, size(z1, 2), n_samples_graph));
sample_points = mean((z1(:, idx) + z2(:, idx)) / 2, 2);
graph = calculate_branch_centers(graph, node_coordinates);
distances = pdist2(midpoints, graph.Nodes.branch_centers);
[~, branch_idx] = min(distances, [], 2);
diam_tab.branch_id = branch_idx;
diameters_table = diam_tab;
end
function graph = calculate_branch_centers(graph, node_coordinates)
n_edges = height(graph.Edges);
branch_centers = zeros(n_edges, 2);
for i = 1:n_edges
node1 = graph.Edges.EndNodes(i, 1);
node2 = graph.Edges.EndNodes(i, 2);
p1 = node_coordinates(node1, :);
p2 = node_coordinates(node2, :);
branch_centers(i, 🙂 = (p1 + p2) / 2;
end
graph.branch_centers = branch_centers; % it breaks here
end
function [xs, x_names, fs] = load_vars(trial)
ts = trial.load_var("tseries");
diam_tab = ts.load_var("diameters");
diam_tab = segment_vessel_table(ts, diam_tab);
dt = diam_tab{:, "y"};
t = diam_tab.x;
t = t(1,:);
xs = TimeSeries(t, dt’);
x_names = "diameter";
% Freq bands is another part that works and not shown atm
for i = 1:size(freq_bands,1)
name = freq_bands{i,1};
xs = [xs; bands.(name)];
x_names = [x_names; name];
end
endI have a graph structure that is formed after binarizing an image of blood vessels and obtaining the skeleton, then creating a graph structure. The graph looks like this:
K >> graph =
graph with properties:
Edges: [773×2 table]
Nodes: [773×0 table]
Which means I have 773 edges and each edge has 2 vertices. The graph edges look like this:
EndNodes Weight
__________ ______
1 2 1
1 53 1.4142
2 3 1
3 4 1
4 5 1
Now, at the end of the graph creation, I have other helper functions that help me create a diameters table with points that have been inferred on the binary image between the vessel walls. So, for each graph point the algorithm tries to look for walls and once found it saves the coordinates and other values in a table.
This is how the table gets created and how it looks like:
diam_tab = table();
for i = 1:n_line % for all the lines detected
row = cell(1,7);
row{1} = dt(i,:); % the diameter measured
row{2} = t; % the time dimension
row{3} = fs; % the frame sampling rate
row{4} = squeeze(permute(w1_t(i,:,:), [1, 3, 2])); % The value coordiantes of the first wall
row{5} = squeeze(permute(w2_t(i,:,:), [1, 3, 2])); % The value coordinates of the second wall
row{6} = line_type(i); % just a string, not relevant
row{7} = util.make_uuid(); % an UUID attached
diam_tab = [diam_tab; row];
end
And finally look like this:
y x fs z1 z2 type UUID
______________ ______________ ______ ________________ ________________ ________ ________________________________________
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘6ada1ae1-00f8-4d9b-aa7a-80c7be26aaa1’}
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘b8da617c-f55f-418c-88dc-5862c968a637’}
Now, what I want to do is, modify this table so that it doesn’t take all of the 773 rows but instead only like an average of the diameters over a certain segment of the graph. Let’s suppose say that the graph has a Y shape, I would like to obtain, every lets say 10 points an average diameter of that section.
Then, finally, the diam_tab table will not have 773 rows, but only the ones left after averaging over several sections of the graph, let’s say for a graph length of 100 the result would be 100 rows, but I want to get instead the average of the graph at sections of length for ex 10, which would leave me with 10 rows.
And finally, the diam_table would be updated to reflect these values, or at the very least replaced by a similar functioning table.
So far, this is what I turned up with in my code, which isn’t exactly working well as it seems to only get center points between two nodes and then breaks when I attach the created structure to the graph.
function diameters_table = segment_vessel_table(ts, diam_tab)
graph = ts.load_var(‘center_line’).graph;
[y, x] = find(ts.load_var(‘binary_image’));
node_coordinates = [x, y];
n_vessels = height(diam_tab);
midpoints = zeros(n_vessels, 2);
n_samples_graph = 5;
for i = 1:n_vessels
z1 = diam_tab.z1{i};
z2 = diam_tab.z2{i};
mids = (z1 + z2) / 2;
midpoints(i, 🙂 = mean(mids, 2);
end
idx = round(linspace(1, size(z1, 2), n_samples_graph));
sample_points = mean((z1(:, idx) + z2(:, idx)) / 2, 2);
graph = calculate_branch_centers(graph, node_coordinates);
distances = pdist2(midpoints, graph.Nodes.branch_centers);
[~, branch_idx] = min(distances, [], 2);
diam_tab.branch_id = branch_idx;
diameters_table = diam_tab;
end
function graph = calculate_branch_centers(graph, node_coordinates)
n_edges = height(graph.Edges);
branch_centers = zeros(n_edges, 2);
for i = 1:n_edges
node1 = graph.Edges.EndNodes(i, 1);
node2 = graph.Edges.EndNodes(i, 2);
p1 = node_coordinates(node1, :);
p2 = node_coordinates(node2, :);
branch_centers(i, 🙂 = (p1 + p2) / 2;
end
graph.branch_centers = branch_centers; % it breaks here
end
function [xs, x_names, fs] = load_vars(trial)
ts = trial.load_var("tseries");
diam_tab = ts.load_var("diameters");
diam_tab = segment_vessel_table(ts, diam_tab);
dt = diam_tab{:, "y"};
t = diam_tab.x;
t = t(1,:);
xs = TimeSeries(t, dt’);
x_names = "diameter";
% Freq bands is another part that works and not shown atm
for i = 1:size(freq_bands,1)
name = freq_bands{i,1};
xs = [xs; bands.(name)];
x_names = [x_names; name];
end
end I have a graph structure that is formed after binarizing an image of blood vessels and obtaining the skeleton, then creating a graph structure. The graph looks like this:
K >> graph =
graph with properties:
Edges: [773×2 table]
Nodes: [773×0 table]
Which means I have 773 edges and each edge has 2 vertices. The graph edges look like this:
EndNodes Weight
__________ ______
1 2 1
1 53 1.4142
2 3 1
3 4 1
4 5 1
Now, at the end of the graph creation, I have other helper functions that help me create a diameters table with points that have been inferred on the binary image between the vessel walls. So, for each graph point the algorithm tries to look for walls and once found it saves the coordinates and other values in a table.
This is how the table gets created and how it looks like:
diam_tab = table();
for i = 1:n_line % for all the lines detected
row = cell(1,7);
row{1} = dt(i,:); % the diameter measured
row{2} = t; % the time dimension
row{3} = fs; % the frame sampling rate
row{4} = squeeze(permute(w1_t(i,:,:), [1, 3, 2])); % The value coordiantes of the first wall
row{5} = squeeze(permute(w2_t(i,:,:), [1, 3, 2])); % The value coordinates of the second wall
row{6} = line_type(i); % just a string, not relevant
row{7} = util.make_uuid(); % an UUID attached
diam_tab = [diam_tab; row];
end
And finally look like this:
y x fs z1 z2 type UUID
______________ ______________ ______ ________________ ________________ ________ ________________________________________
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘6ada1ae1-00f8-4d9b-aa7a-80c7be26aaa1’}
1×19682 double 1×19682 double 21.383 {2×19682 double} {2×19682 double} "vessel" {‘b8da617c-f55f-418c-88dc-5862c968a637’}
Now, what I want to do is, modify this table so that it doesn’t take all of the 773 rows but instead only like an average of the diameters over a certain segment of the graph. Let’s suppose say that the graph has a Y shape, I would like to obtain, every lets say 10 points an average diameter of that section.
Then, finally, the diam_tab table will not have 773 rows, but only the ones left after averaging over several sections of the graph, let’s say for a graph length of 100 the result would be 100 rows, but I want to get instead the average of the graph at sections of length for ex 10, which would leave me with 10 rows.
And finally, the diam_table would be updated to reflect these values, or at the very least replaced by a similar functioning table.
So far, this is what I turned up with in my code, which isn’t exactly working well as it seems to only get center points between two nodes and then breaks when I attach the created structure to the graph.
function diameters_table = segment_vessel_table(ts, diam_tab)
graph = ts.load_var(‘center_line’).graph;
[y, x] = find(ts.load_var(‘binary_image’));
node_coordinates = [x, y];
n_vessels = height(diam_tab);
midpoints = zeros(n_vessels, 2);
n_samples_graph = 5;
for i = 1:n_vessels
z1 = diam_tab.z1{i};
z2 = diam_tab.z2{i};
mids = (z1 + z2) / 2;
midpoints(i, 🙂 = mean(mids, 2);
end
idx = round(linspace(1, size(z1, 2), n_samples_graph));
sample_points = mean((z1(:, idx) + z2(:, idx)) / 2, 2);
graph = calculate_branch_centers(graph, node_coordinates);
distances = pdist2(midpoints, graph.Nodes.branch_centers);
[~, branch_idx] = min(distances, [], 2);
diam_tab.branch_id = branch_idx;
diameters_table = diam_tab;
end
function graph = calculate_branch_centers(graph, node_coordinates)
n_edges = height(graph.Edges);
branch_centers = zeros(n_edges, 2);
for i = 1:n_edges
node1 = graph.Edges.EndNodes(i, 1);
node2 = graph.Edges.EndNodes(i, 2);
p1 = node_coordinates(node1, :);
p2 = node_coordinates(node2, :);
branch_centers(i, 🙂 = (p1 + p2) / 2;
end
graph.branch_centers = branch_centers; % it breaks here
end
function [xs, x_names, fs] = load_vars(trial)
ts = trial.load_var("tseries");
diam_tab = ts.load_var("diameters");
diam_tab = segment_vessel_table(ts, diam_tab);
dt = diam_tab{:, "y"};
t = diam_tab.x;
t = t(1,:);
xs = TimeSeries(t, dt’);
x_names = "diameter";
% Freq bands is another part that works and not shown atm
for i = 1:size(freq_bands,1)
name = freq_bands{i,1};
xs = [xs; bands.(name)];
x_names = [x_names; name];
end
end graph, table, handles, image processing MATLAB Answers — New Questions
How do I configure the default camera views in unreal engine co-simulation?
I am using the aerospace toolbox and passing vehicle dynamic state into unreal engine. Everything works great except the camera views in unreal engine editor. I am using Cesium ion which only renders tiles in the vicinity of the main camera fucrum. I have multiple camera views such as one looking down from the top of my rocket at the fins which does not render. The vehicle is relatively small and the default viewer camera angles are very far away from the vehicle. Is there a way to re-configure the default camera views or fix my problem with cesium rendering?I am using the aerospace toolbox and passing vehicle dynamic state into unreal engine. Everything works great except the camera views in unreal engine editor. I am using Cesium ion which only renders tiles in the vicinity of the main camera fucrum. I have multiple camera views such as one looking down from the top of my rocket at the fins which does not render. The vehicle is relatively small and the default viewer camera angles are very far away from the vehicle. Is there a way to re-configure the default camera views or fix my problem with cesium rendering? I am using the aerospace toolbox and passing vehicle dynamic state into unreal engine. Everything works great except the camera views in unreal engine editor. I am using Cesium ion which only renders tiles in the vicinity of the main camera fucrum. I have multiple camera views such as one looking down from the top of my rocket at the fins which does not render. The vehicle is relatively small and the default viewer camera angles are very far away from the vehicle. Is there a way to re-configure the default camera views or fix my problem with cesium rendering? unreal engine, cesium, aerospace toolbox, aerospace blockset, visualization, simulation, simulink MATLAB Answers — New Questions
exporting-to-excel-spreadsheets
Hello, I am trying to do what I feel is very basic task. I have numerous excel files. Parameter name across the top row, data point from row 2:xxxx.
What I want to be able to do is go through a number of files, grab the filenames, column x name for title, and say search for the highest poinit in that column, or calculate average of that column.
I’m struggling to really understand how to do this, I’m no programmer, that is 100% certain. If I could get something put together to do this I feel that it could help to me process a majority of the files I work with, not doing this exact task, but very similar. I’ve not had the best of luck finding responses by searching forums, etc to do this for people who don’t understand programming, so I’m looking for an idiots guide to how to do basic tasks like this with matlab. If anyone has something they think would help, please post up.
Thanks!Hello, I am trying to do what I feel is very basic task. I have numerous excel files. Parameter name across the top row, data point from row 2:xxxx.
What I want to be able to do is go through a number of files, grab the filenames, column x name for title, and say search for the highest poinit in that column, or calculate average of that column.
I’m struggling to really understand how to do this, I’m no programmer, that is 100% certain. If I could get something put together to do this I feel that it could help to me process a majority of the files I work with, not doing this exact task, but very similar. I’ve not had the best of luck finding responses by searching forums, etc to do this for people who don’t understand programming, so I’m looking for an idiots guide to how to do basic tasks like this with matlab. If anyone has something they think would help, please post up.
Thanks! Hello, I am trying to do what I feel is very basic task. I have numerous excel files. Parameter name across the top row, data point from row 2:xxxx.
What I want to be able to do is go through a number of files, grab the filenames, column x name for title, and say search for the highest poinit in that column, or calculate average of that column.
I’m struggling to really understand how to do this, I’m no programmer, that is 100% certain. If I could get something put together to do this I feel that it could help to me process a majority of the files I work with, not doing this exact task, but very similar. I’ve not had the best of luck finding responses by searching forums, etc to do this for people who don’t understand programming, so I’m looking for an idiots guide to how to do basic tasks like this with matlab. If anyone has something they think would help, please post up.
Thanks! excel, export, basic MATLAB Answers — New Questions
How do I determine if a column header exists in a table?
I am performing a readtable() command. Sometimes the table contains a column called "x"; sometimes it is called "y". How would you determine if one column exists or not. I looked through the is* functions but did not see anything that I could use in an if statement.I am performing a readtable() command. Sometimes the table contains a column called "x"; sometimes it is called "y". How would you determine if one column exists or not. I looked through the is* functions but did not see anything that I could use in an if statement. I am performing a readtable() command. Sometimes the table contains a column called "x"; sometimes it is called "y". How would you determine if one column exists or not. I looked through the is* functions but did not see anything that I could use in an if statement. existing column MATLAB Answers — New Questions