Author: PuTI
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
How agentic AI is driving AI-first business transformation for customers to achieve more
The role of agentic AI has grown rapidly over the past several months as organizational leaders seek ways to accelerate AI Transformation. We firmly believe that Agents + Copilot + Human Ambition can deliver real AI differentiation for our customers. By putting the autonomous capabilities of an agent to work for their businesses, our customers are unlocking AI opportunity to realize greater value. The recent introduction of Microsoft 365 Copilot Chat is delivering on our promise of “Copilot for all” by providing frontline workers with a free, secure and enterprise-ready AI chat interface. Our customers are building their own custom agents with the no-code, low-code features of Microsoft Copilot Studio, allowing citizen and professional developers to extend the capabilities of Copilot and deliver on the unique needs of their industry. We also offer the best prebuilt agent framework right out-of-the-box, such as Sales Agent that works autonomously to help sellers build pipeline and close more deals with greater speed. Similarly, we recently announced general purpose reasoning agents — such as Researcher and Analyst — and invite all of our Microsoft 365 Copilot users to try these in their environments.
It is exciting to see how agents are driving pragmatic AI innovation for our customers by increasing productivity, creating capacity across every role and function and improving business processes. Below are a few highlights from the past quarter that underscore the impact of an agentic AI approach — from improving employee experiences to streamlined workflows and significant cost savings.
Agentic service management software provider Atomicwork leveraged Azure AI Foundry to create Atom — an AI agent that transforms the digital workplace experience for employees and automates service delivery. Adopters of this agentic management platform recognize significant benefits, such as reduced operational costs and increased employee satisfaction, with one customer achieving a 65% deflection rate within six months of implementation and projections of 80% by the end of the year. Integration within Microsoft Teams and other enterprise tools have further streamlined service delivery, allowing employees easier access to information and support. The company’s AI-driven approach has resulted in a 20% increase in accuracy and 75% reduction in response latency when compared to competing solutions.
To support employees as they manage the high demand of internal requests and to create a more satisfying work environment, BDO Colombia used Copilot Studio and Power Platform to develop BeTic 2.0 — an agent that centralizes and automates key payroll and finance processes. The agent reduced operational workload by 50%, optimized 78% of internal processes and showed 99.9% accuracy in managed requests. It also helped reduce duplicative work, optimized workflows, improved the employee-client experience and continues to serve as a competitive differentiator for the company in the market.
Dow is using agents to automate the shipping invoice analysis process and streamline its global supply chain to unlock new efficiencies and value. Receiving more than 100,000 shipping invoices via PDF each year, Dow built an autonomous agent in Copilot Studio to scan for billing inaccuracies and surface them in a dashboard for employee review. Using Freight Agent — a second agent built in Copilot Studio — employees can investigate further by “dialoguing with the data” in natural language. The agents are helping employees solve the challenge of hidden losses autonomously within minutes rather than weeks or months. Dow expects to save millions of dollars on shipping costs through increased accuracy in logistic rates and billing within the first year.
As a leading provider of sustainable energy in Belgium, Eneco serves over 1.5 million customers. Facing performance issues with their existing chatbot, Eneco developed a new AI-driven agent using the no-code, graphical interface in Copilot Studio. This multilingual agent was deployed on the company website in just three months, integrating seamlessly with its live chat platform. The new agent manages 24,000 chats per month — an increase of 140% over the previous solution — and resolves 70% more customer conversations without a handoff to a live representative. For requests that do require escalation, the agent provides an AI-generated summary of the conversation for a more optimized call center experience.
To reimagine trend forecasting and consumer marketing, The Estée Lauder Companies Inc. leveraged Copilot Studio to develop ConsumerIQ — an agent that centralizes and streamlines consumer data to enable instant access to actionable insights. Using natural language prompts, the agent reduced the time required for marketers to gather data from hours to seconds, while accelerating decision-making and helping prevent duplicated research. Together with Azure OpenAI Service and Azure AI Search, teams can gather data, identify trends, build marketing assets, inform research and move products to market faster.
To create proposals and streamline knowledge retrieval and organization, Fujitsu leveraged Azure AI Agent Service within Azure AI Foundry to develop an intelligent, scalable AI agent for sales automation. The agent boosted productivity of sales teams by 67% while addressing knowledge gaps and allowing them to build stronger customer relationships. This transformation allowed teams to shift from time-intensive tasks to strategic planning and customer relationship building, while also supporting new hires with product information and strategic guidance.
To reduce manual tasks and help employees deliver exceptional experiences, global baker Grupo Bimbo established its first ever technology Center of Excellence. Using Power Platform solutions and Copilot Studio, teams created 7,000 power apps, 18,000 processes and 650 agents to reduce busy work and enhance consumer service. By automating low-value tasks, the company saved tens of millions of dollars annually in development efforts and operational efficiencies. Grupo Bimbo also migrated to Azure for its AI capabilities, scalability, security and rapid time to market for apps.
KPMG developed Comply AI — an agent that helps identify environment, social and governance compliance. Using Microsoft AI technologies, the agent helps identify relevant obligations, generate statements in natural language, assess control effectiveness and redraft control descriptions. This has already helped one of its customers achieve 70% improvement in Controls and Risks descriptions, an 18-month reduction in compliance program timelines and a 50% cut in ongoing compliance efforts. KPMG is also using an agent to support new hires by providing templates and historical references to speed up the onboarding process and reduce follow-up calls by 20%.
To significantly enhance its customer service operations, T-Mobile used Power Apps to develop PromoGenius — an app that combines promotional data from multiple systems and documents to keep frontline retail employees equipped with the latest promotional information for customers. Using Copilot Studio, the company embedded an agent in the app so customer service representatives can instantly search for technical details from device manufacturers and create a customer-facing view of product information in a fraction of the time a manual search would require. PromoGenius is the second most-used app in the company, with 83,000 unique users and 500,000 launches a month.
Using Copilot Studio, Virgin Money developed Redi — an agent serving as a digital host within a mobile app for credit card customers. The agent, trained to understand colloquialisms and even known to tell jokes, serves as a secure way for customers to get answers quickly while understanding appropriate context for when a live representative is required. The company views this agent as a tool for its employees to better serve customers, handling over one million interactions, boosting customer satisfaction and becoming one of the bank’s top-rated service channels. Redi now supports customers across Virgin Money’s digital platforms and has been recognized with an industry award for AI in financial services.
To help employees navigate countless procedures, evolving regulations and complex banking systems, Wells Fargo built an agent through Teams to ensure fast and accurate customer support. Using large language models, the agent provides instant access to guidance on 1,700 internal procedures across 4,000 bank branches. Employees can now locate needed information faster without support from a colleague, with 75% of searches happening through the agent and response times reduced from 10 minutes to 30 seconds.
There is immense potential for agents to drive AI-first differentiation for organizations everywhere, especially when combined with Copilot and human ambition. At Microsoft, we believe AI is about empowering human achievement, unlocking potential and democratizing intelligence for as many people as possible with our cloud and AI solutions — as evidenced by these AI Transformation stories of more than 700 customers and partners. I look forward to partnering with you to unlock continued AI opportunity, drive pragmatic innovation and realize meaningful business impact for your organization.
The post How agentic AI is driving AI-first business transformation for customers to achieve more appeared first on The Official Microsoft Blog.
The role of agentic AI has grown rapidly over the past several months as organizational leaders seek ways to accelerate AI Transformation. We firmly believe that Agents + Copilot + Human Ambition can deliver real AI differentiation for our customers. By putting the autonomous capabilities of an agent to work for their businesses, our customers…
The post How agentic AI is driving AI-first business transformation for customers to achieve more appeared first on The Official Microsoft Blog.Read More
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 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
My 6×6 symbolic Jacobian matrix is massive, and matlabFunction( ) is having trouble writing the corresponding numerical function file.
Hi there!
I currently have a 6×6 symoblic Jacobian using the Symbolic Math Toolbox. It is massive, when I take a peek at it using the Command Window. I then used matlabFunction( ) to convert this symbolic Jacobian to a numerical function. If I use matlabFunction’s default optimize = true, the numerical function file is about 8,000 lines of code, and I get a message there that says the code is too complex to analyze, and that I should reduce the number of operations in my code. On the other hand, if I use matlabFunction’s optimize = false option, the numerical function file is 59,506 lines of code, and I get a message there that says the file is too large. I then tried passing to matlabFunction( ), "Sparse", true, to try to get a sparse numerical Jacobian function file, but I still get the message in the numerical file that the code is too complex to analyze.
What can I do from here?
My goal is to successfully get a numerical Jacobian function file, then evaluate it to get a numerical Jacobian, and then find its eigenvalues using eig( ).
Thanks in advance,Hi there!
I currently have a 6×6 symoblic Jacobian using the Symbolic Math Toolbox. It is massive, when I take a peek at it using the Command Window. I then used matlabFunction( ) to convert this symbolic Jacobian to a numerical function. If I use matlabFunction’s default optimize = true, the numerical function file is about 8,000 lines of code, and I get a message there that says the code is too complex to analyze, and that I should reduce the number of operations in my code. On the other hand, if I use matlabFunction’s optimize = false option, the numerical function file is 59,506 lines of code, and I get a message there that says the file is too large. I then tried passing to matlabFunction( ), "Sparse", true, to try to get a sparse numerical Jacobian function file, but I still get the message in the numerical file that the code is too complex to analyze.
What can I do from here?
My goal is to successfully get a numerical Jacobian function file, then evaluate it to get a numerical Jacobian, and then find its eigenvalues using eig( ).
Thanks in advance, Hi there!
I currently have a 6×6 symoblic Jacobian using the Symbolic Math Toolbox. It is massive, when I take a peek at it using the Command Window. I then used matlabFunction( ) to convert this symbolic Jacobian to a numerical function. If I use matlabFunction’s default optimize = true, the numerical function file is about 8,000 lines of code, and I get a message there that says the code is too complex to analyze, and that I should reduce the number of operations in my code. On the other hand, if I use matlabFunction’s optimize = false option, the numerical function file is 59,506 lines of code, and I get a message there that says the file is too large. I then tried passing to matlabFunction( ), "Sparse", true, to try to get a sparse numerical Jacobian function file, but I still get the message in the numerical file that the code is too complex to analyze.
What can I do from here?
My goal is to successfully get a numerical Jacobian function file, then evaluate it to get a numerical Jacobian, and then find its eigenvalues using eig( ).
Thanks in advance, jacobian symbolic numerical matlab MATLAB Answers — New Questions
Why do I receive the error regarding “polyspace.connector.Service” when using the report generator?
While trying report generation, the following error is thrown:
Location: null, user name: xxxxxxxxx,
id: xxx@xxxxxxx, print mode: false Polyspace Report Generator Loading results Error: matlab.internal.webservices.HTTPConnector/copyContentToByteArray (Line 373)
The server returned the status 503 with message "Service Unavailable" in response to the request to URL URL http://localhost:9254/metadata.
However, if I run the analysis and then generate a report, the following message is thrown:
error: polyspace.connector.Service/nGetPort (line 198)
No available ports found in the range 9093-10093
error: polyspace.connector.Service (line 88)
error: polyspace.connector.Query (line 37)
error: PolySpaceResult/Query (line 400)
error: PolySpaceResult/GetResultProperties (line 607)
error: PolySpaceResult/Initialise (line 471)
error: PolySpaceResult (line 103)
error: PolySpaceResultInterface (line 279)
error: polyspace_report_internal (line 174)
error: psrptgenprivate (line 19)
error: polyspace_report (line 7)
polyspace:pscore:noPortForConnectorError
**********************************************************
***
*** Report generation done
***
**********************************************************While trying report generation, the following error is thrown:
Location: null, user name: xxxxxxxxx,
id: xxx@xxxxxxx, print mode: false Polyspace Report Generator Loading results Error: matlab.internal.webservices.HTTPConnector/copyContentToByteArray (Line 373)
The server returned the status 503 with message "Service Unavailable" in response to the request to URL URL http://localhost:9254/metadata.
However, if I run the analysis and then generate a report, the following message is thrown:
error: polyspace.connector.Service/nGetPort (line 198)
No available ports found in the range 9093-10093
error: polyspace.connector.Service (line 88)
error: polyspace.connector.Query (line 37)
error: PolySpaceResult/Query (line 400)
error: PolySpaceResult/GetResultProperties (line 607)
error: PolySpaceResult/Initialise (line 471)
error: PolySpaceResult (line 103)
error: PolySpaceResultInterface (line 279)
error: polyspace_report_internal (line 174)
error: psrptgenprivate (line 19)
error: polyspace_report (line 7)
polyspace:pscore:noPortForConnectorError
**********************************************************
***
*** Report generation done
***
********************************************************** While trying report generation, the following error is thrown:
Location: null, user name: xxxxxxxxx,
id: xxx@xxxxxxx, print mode: false Polyspace Report Generator Loading results Error: matlab.internal.webservices.HTTPConnector/copyContentToByteArray (Line 373)
The server returned the status 503 with message "Service Unavailable" in response to the request to URL URL http://localhost:9254/metadata.
However, if I run the analysis and then generate a report, the following message is thrown:
error: polyspace.connector.Service/nGetPort (line 198)
No available ports found in the range 9093-10093
error: polyspace.connector.Service (line 88)
error: polyspace.connector.Query (line 37)
error: PolySpaceResult/Query (line 400)
error: PolySpaceResult/GetResultProperties (line 607)
error: PolySpaceResult/Initialise (line 471)
error: PolySpaceResult (line 103)
error: PolySpaceResultInterface (line 279)
error: polyspace_report_internal (line 174)
error: psrptgenprivate (line 19)
error: polyspace_report (line 7)
polyspace:pscore:noPortForConnectorError
**********************************************************
***
*** Report generation done
***
********************************************************** polyspace, connector, report, generator, firewall, antivirus 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
Simulink windows turn yellow almost always.
This is an example. This is data inspector in simulink as an example, other windows mostly do the same. I have been looking on the internet for a solution but found nothing. This is on a new laptop and this issue does not occur on any other program I use. anyone having a similar issue?This is an example. This is data inspector in simulink as an example, other windows mostly do the same. I have been looking on the internet for a solution but found nothing. This is on a new laptop and this issue does not occur on any other program I use. anyone having a similar issue? This is an example. This is data inspector in simulink as an example, other windows mostly do the same. I have been looking on the internet for a solution but found nothing. This is on a new laptop and this issue does not occur on any other program I use. anyone having a similar issue? simulink gui MATLAB Answers — New Questions
Inverting an 8×8 symbolic matrix
I am trying to invert an 8×8 symbolic matrix with 32 symbolic variables in total. However, when running the standard inversion methods with inv() or mldivide(), the program takes a lot of time and ended up crashing all the times I tried to invert this matrix. I tried some workarounds, such as a recursive inversion algorithm using Schur decomposition and other ways of using the fact that I know that the matrix is symmetric, but to no avail. The function has a lot of sines and cosines of these variables, which might also be a problem.
I am looking for ways I can get this matrix inverted, or any further suggestion on how to tackle this problem.
Thanks in advance.
For context: the matrix I am trying to invert is the inertia matrix for a tiltrotor UAV. the 32 parameters consist of 6 state variables and 26 model parameters. My goal with this is to get an analytic expression for the system equations of motion:
With that expression, I intend to obtain an analytic linearization of the system in order to get a linear model , where . With these analytical expressions should be able to easily get A, B matrices for different values of the system parameters and formulate robust linear controllers with polytopic uncertainty.I am trying to invert an 8×8 symbolic matrix with 32 symbolic variables in total. However, when running the standard inversion methods with inv() or mldivide(), the program takes a lot of time and ended up crashing all the times I tried to invert this matrix. I tried some workarounds, such as a recursive inversion algorithm using Schur decomposition and other ways of using the fact that I know that the matrix is symmetric, but to no avail. The function has a lot of sines and cosines of these variables, which might also be a problem.
I am looking for ways I can get this matrix inverted, or any further suggestion on how to tackle this problem.
Thanks in advance.
For context: the matrix I am trying to invert is the inertia matrix for a tiltrotor UAV. the 32 parameters consist of 6 state variables and 26 model parameters. My goal with this is to get an analytic expression for the system equations of motion:
With that expression, I intend to obtain an analytic linearization of the system in order to get a linear model , where . With these analytical expressions should be able to easily get A, B matrices for different values of the system parameters and formulate robust linear controllers with polytopic uncertainty. I am trying to invert an 8×8 symbolic matrix with 32 symbolic variables in total. However, when running the standard inversion methods with inv() or mldivide(), the program takes a lot of time and ended up crashing all the times I tried to invert this matrix. I tried some workarounds, such as a recursive inversion algorithm using Schur decomposition and other ways of using the fact that I know that the matrix is symmetric, but to no avail. The function has a lot of sines and cosines of these variables, which might also be a problem.
I am looking for ways I can get this matrix inverted, or any further suggestion on how to tackle this problem.
Thanks in advance.
For context: the matrix I am trying to invert is the inertia matrix for a tiltrotor UAV. the 32 parameters consist of 6 state variables and 26 model parameters. My goal with this is to get an analytic expression for the system equations of motion:
With that expression, I intend to obtain an analytic linearization of the system in order to get a linear model , where . With these analytical expressions should be able to easily get A, B matrices for different values of the system parameters and formulate robust linear controllers with polytopic uncertainty. symbolic, matrix, inverse MATLAB Answers — New Questions
Solve DAEs using IDASolve function of SUNDIALS 2.6.2 version
I am trying to solve the system of differential algebraic equations which are used to model the IEEE 9 bus system. The differential equations determines the dynamic behaviour of the generators while the algebraic equations consists of the stator and the network (power flow) equations.
I have attached a MATLAB code in which the function "fun_DAE" gives out all of the equations in the form of a column vectors. ‘ F_D ‘ gives the 21 differential equations (7 for each generator), ‘ F_SA ‘ gives 18 network equations (real and reactive power balances for 9 buses) and ‘ F_SA’ gives the 6 stator equations (2 for each generator). ‘ F_SA’ and ‘ F_N ‘ constitutes the algebraic constraints.
the differential variables are for each generator. The initial values of this state variables are calculated and stored as matrix.
I need some help in using the IDAInit, IDASetOptions and IDASolve functions or any other relevant functions to be used to get a solution.
Thank You.I am trying to solve the system of differential algebraic equations which are used to model the IEEE 9 bus system. The differential equations determines the dynamic behaviour of the generators while the algebraic equations consists of the stator and the network (power flow) equations.
I have attached a MATLAB code in which the function "fun_DAE" gives out all of the equations in the form of a column vectors. ‘ F_D ‘ gives the 21 differential equations (7 for each generator), ‘ F_SA ‘ gives 18 network equations (real and reactive power balances for 9 buses) and ‘ F_SA’ gives the 6 stator equations (2 for each generator). ‘ F_SA’ and ‘ F_N ‘ constitutes the algebraic constraints.
the differential variables are for each generator. The initial values of this state variables are calculated and stored as matrix.
I need some help in using the IDAInit, IDASetOptions and IDASolve functions or any other relevant functions to be used to get a solution.
Thank You. I am trying to solve the system of differential algebraic equations which are used to model the IEEE 9 bus system. The differential equations determines the dynamic behaviour of the generators while the algebraic equations consists of the stator and the network (power flow) equations.
I have attached a MATLAB code in which the function "fun_DAE" gives out all of the equations in the form of a column vectors. ‘ F_D ‘ gives the 21 differential equations (7 for each generator), ‘ F_SA ‘ gives 18 network equations (real and reactive power balances for 9 buses) and ‘ F_SA’ gives the 6 stator equations (2 for each generator). ‘ F_SA’ and ‘ F_N ‘ constitutes the algebraic constraints.
the differential variables are for each generator. The initial values of this state variables are calculated and stored as matrix.
I need some help in using the IDAInit, IDASetOptions and IDASolve functions or any other relevant functions to be used to get a solution.
Thank You. sundials, ode MATLAB Answers — New Questions
MATLAB’s volshow command displays gray pixels as the inverse RGB color of any colored pixels also present in the dataset
I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase
Volshow Image Showing Gray = Yellow with Blue Colored Phase
I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase
Volshow Image Showing White = White with Blue Colored Phase
I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase
Volshow Image Showing Gray = Cyan with Red Colored Phase
The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase
Volshow Image Showing Gray = Gray with White Colored Phase
I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases
Volshow Image Showing Gray = Green with Blue and Red Colored Phases
I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc
% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);
% Import image message
clc
fprintf(‘Importing image stack…nn’)
% Create tiff
stack_tiff = Tiff(file_path);
% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);
% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);
% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);
% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);
% Import loop
for n = 2:no_slice
% Update current directory
nextDirectory(stack_tiff);
% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);
end
% Close tiff
close(stack_tiff)
% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);
% Create viewer parameters structure
view_struct = struct;
% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;
% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);
% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);
% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;
% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);
% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);
% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);
% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);
% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);
% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);
% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);
% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);
% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;
% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);
% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);
% End message
clc
fprintf(‘Finished!nn’)I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase
Volshow Image Showing Gray = Yellow with Blue Colored Phase
I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase
Volshow Image Showing White = White with Blue Colored Phase
I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase
Volshow Image Showing Gray = Cyan with Red Colored Phase
The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase
Volshow Image Showing Gray = Gray with White Colored Phase
I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases
Volshow Image Showing Gray = Green with Blue and Red Colored Phases
I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc
% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);
% Import image message
clc
fprintf(‘Importing image stack…nn’)
% Create tiff
stack_tiff = Tiff(file_path);
% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);
% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);
% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);
% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);
% Import loop
for n = 2:no_slice
% Update current directory
nextDirectory(stack_tiff);
% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);
end
% Close tiff
close(stack_tiff)
% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);
% Create viewer parameters structure
view_struct = struct;
% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;
% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);
% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);
% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;
% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);
% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);
% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);
% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);
% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);
% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);
% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);
% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);
% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;
% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);
% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);
% End message
clc
fprintf(‘Finished!nn’) I have a segmented 3D image dataset that I am trying to visualize. Because there are two segmented phases, I am exploring different colors for each phase to make them stand out from each other. In particular, I would like one of the phases to be blue (RGB [0, 0, 255]) and the other phase to be gray (RGB [128, 128, 128]). I have created a 4D uint8 dataset of the segmented images to allow for this, and when I load the image stack in MATLAB’s sliceViewer everything looks correct. However, when I then load the same dataset in MATLAB’s volshow, it colors the gray pixels yellow while the blue pixels remain blue. See pictures below:
SliceViewer Image Showing Gray = Gray with Blue Colored Phase
Volshow Image Showing Gray = Yellow with Blue Colored Phase
I thought that perhaps there was an issue with the lighting option being colored and casting a color onto gray pixels, but I have the lighting option turned off. I then thought that perhaps there was an issue with grayscale pixels in volshow, but when I convert the gray pixels to white (RGB [255, 255, 255]) they appear white in volshow. The same exact effect is achieved if the blue pixels are reduced in intensity to RGB [0, 0, 128] while leaving the gray pixels as RGB [128, 128, 128] (the sliceViewer will look different showing a darker blue but the volshow looks identical to the picture below with a bright blue and white-colored gray pixels). See pictures below:
SliceViewer Image Showing White = White with Blue Colored Phase
Volshow Image Showing White = White with Blue Colored Phase
I then explored other colors to see if there is a specific issue with the blue/gray combination and found interesting results. When I converted the blue pixels to red (RGB [255, 0, 0]), the gray pixels remained gray in sliceViewer but now display as cyan in volshow. See pictures below:
SliceViewer Image Showing Gray = Gray with Red Colored Phase
Volshow Image Showing Gray = Cyan with Red Colored Phase
The blue/gray and red/gray tests demonstrate that volshow will replace gray pixels with the inverse RGB color of any colored pixels in the dataset (yellow is the opposite RGB of blue ([255, 255, 0] vs. [0, 0, 255]) and cyan is the opposite RGB of red ([0, 255, 255] vs. [255, 0, 0])). However, the yellow and cyan colors do not appear to be their full intensity versions ([255, 255, 0] for yellow and [0, 255, 255] for cyan) and they may have some degree of their typically absent color present, but I cannot tell as these pixels do not actually have these intensity values in the image data so I cannot tell to what the true color is that they are creating. Thus, I cannot determine to what degree the opposite colors are added and the main color is substracted from the gray pixels.
I then tried substituting the colored phase for white to see if that maintained the gray pixels, and this worked (note that it may be difficult to see the difference between white and gray in the volShow, but I turned the volume around, zoomed in, and was able to verify that this was the case). See pictures below:
SliceViewer Image Showing Gray = Gray with White Colored Phase
Volshow Image Showing Gray = Gray with White Colored Phase
I was then curious as to what would happen to the gray pixels if I added a third, differently-colored phase. So, I added a red strip down one side of the blue/gray volume. Now, the gray pixels turned green (again, to what degree the blue and red intensities were added vs. substracted and how much of the green intensity was added, I cannot know). See pictures below:
SliceViewer Image Showing Gray = Gray with Blue and Red Colored Phases
Volshow Image Showing Gray = Green with Blue and Red Colored Phases
I don’t know if I am doing something wrong, so I have provided a snippet of code that will re-create all of this as well as a google drive link (the file is >5 MB so I can’t upload it) to the dataset I am using to investigate this. The code will let you select the data and automatically load it for you and then produce all of the images I have included here in there sliceViewer and volshow formats so that you can explore them). Here is the link to the dataset and here is the code:
%% Test Case %%
close all
clear
clc
% Select image file
fprintf(‘Select an image file.nn’)
[file_name, path_intro] = uigetfile(‘*.*’, ‘Select an image file’);
file_path = sprintf(‘%s%s’, path_intro, file_name);
% Import image message
clc
fprintf(‘Importing image stack…nn’)
% Create tiff
stack_tiff = Tiff(file_path);
% Determine number of images in stack
info = imfinfo(file_path);
no_slice = numel(info);
% Determine necessary tags from tiff
bits = getTag(stack_tiff, ‘BitsPerSample’);
long = getTag(stack_tiff, ‘ImageLength’);
wide = getTag(stack_tiff, ‘ImageWidth’);
samples = getTag(stack_tiff, ‘SamplesPerPixel’);
% Pre-allocate volume array
volume = zeros(long, wide, no_slice, samples, ‘uint8’);
% Import first image
volume(:, :, 1, 🙂 = read(stack_tiff);
% Import loop
for n = 2:no_slice
% Update current directory
nextDirectory(stack_tiff);
% Add current slice to volume
volume(:, :, n, 🙂 = read(stack_tiff);
end
% Close tiff
close(stack_tiff)
% Create transformation matrix
T = [1.31 0 0 0; 0 1.31 0 0; 0 0 1.31 0; 0 0 0 1];
tform = affinetform3d(T);
% Create viewer parameters structure
view_struct = struct;
% Populate viewer parameters structure
view_struct.BackgroundColor = [1 1 1];
view_struct.BackgroundGradient = ‘off’;
view_struct.Lighting = ‘off’;
% Load first slice viewer
clc
fprintf(‘Loading first slice viewer…nn’)
f1 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Blue Colored Phase’);
sliceViewer(volume, parent = f1);
% Load first volume viewer
clc
fprintf(‘Loading first volume viewer…nn’)
uif1 = uifigure(‘Name’, ‘Gray = Yellow in Volume Viewer with Blue Colored Phase’);
viewer1 = viewer3d(view_struct, parent = uif1);
V1 = volshow(volume, ‘Transformation’, tform, parent = viewer1);
% Convert gray to white in second volume
clc
fprintf(‘Converting gray to white…nn’)
g2w_vol = volume;
g2w_vol(volume == 128) = 255;
% Load second slice viewer
clc
fprintf(‘Loading second slice viewer…nn’)
f2 = figure(‘Name’, ‘White = White in Slice Viewer with Blue Colored Phase’);
sliceViewer(g2w_vol, parent = f2);
% Load second volume viewer
clc
fprintf(‘Loading second volume viewer…nn’)
uif2 = uifigure(‘Name’, ‘White = White in Volume Viewer with Blue Colored Phase’);
viewer2 = viewer3d(view_struct, parent = uif2);
V2 = volshow(g2w_vol, ‘Transformation’, tform, parent = viewer2);
% Convert blue to red in third volume
clc
fprintf(‘Converting blue to red…nn’)
b2r_vol = volume;
b2r_vol(:, :, :, 1) = volume(:, :, :, 3);
b2r_vol(:, :, :, 3) = volume(:, :, :, 1);
% Load third slice viewer
clc
fprintf(‘Loading third slice viewer…nn’)
f3 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with Red Colored Phase’);
sliceViewer(b2r_vol, parent = f3);
% Load third volume viewer
clc
fprintf(‘Loading third volume viewer…nn’)
uif3 = uifigure(‘Name’, ‘Gray = Cyan in Volume Viewer with Red Colored Phase’);
viewer3 = viewer3d(view_struct, parent = uif3);
V3 = volshow(b2r_vol, ‘Transformation’, tform, parent = viewer3);
% Convert blue to white in fourth volume
clc
fprintf(‘Converting blue to white…nn’)
b2w_vol = volume;
b2w_vol(:, :, :, 1) = volume(:, :, :, 3);
b2w_vol(:, :, :, 2) = volume(:, :, :, 3);
% Load fourth slice viewer
clc
fprintf(‘Loading fourth slice viewer…nn’)
f4 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(b2w_vol, parent = f4);
% Load fourth volume viewer
clc
fprintf(‘Loading fourth volume viewer…nn’)
uif4 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer4 = viewer3d(view_struct, parent = uif4);
V4 = volshow(b2w_vol, ‘Transformation’, tform, parent = viewer4);
% Add red strip in fifth volume
clc
fprintf(‘Adding red strip…nn’)
br_vol = volume;
br_vol(:, 1:25, :, 1) = 255;
br_vol(:, 1:25, :, 2:3) = 0;
% Load fifth slice viewer
clc
fprintf(‘Loading fifth slice viewer…nn’)
f5 = figure(‘Name’, ‘Gray = Gray in Slice Viewer with White Colored Phase’);
sliceViewer(br_vol, parent = f5);
% Load fifth volume viewer
clc
fprintf(‘Loading fifth volume viewer…nn’)
uif5 = uifigure(‘Name’, ‘Gray = Gray in Volume Viewer with White Colored Phase’);
viewer5 = viewer3d(view_struct, parent = uif5);
V5 = volshow(br_vol, ‘Transformation’, tform, parent = viewer5);
% End message
clc
fprintf(‘Finished!nn’) volshow, image processing, image segmentation MATLAB Answers — New Questions
We have tetrahedra mesh we went to extract a sphere from this mesh and adabting the mesh
We do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equalWe do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equal We do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equal sphere in tetrahedra MATLAB Answers — New Questions
Transport Delay in Realtime simulation
Hello,
I set the simulation time to "inf" in order to be able to change the parameters during real-time.
However it seems that Transport Delay block is not working in this mode. When I switch to finite time, it is working, but then I can not change the parameters real-time.
How to solve this?
Thanks
M.Hello,
I set the simulation time to "inf" in order to be able to change the parameters during real-time.
However it seems that Transport Delay block is not working in this mode. When I switch to finite time, it is working, but then I can not change the parameters real-time.
How to solve this?
Thanks
M. Hello,
I set the simulation time to "inf" in order to be able to change the parameters during real-time.
However it seems that Transport Delay block is not working in this mode. When I switch to finite time, it is working, but then I can not change the parameters real-time.
How to solve this?
Thanks
M. delay, simulink, realtime MATLAB Answers — New Questions
How to send data between nodes in an iot network?
I have created a simulation environment for IoT network which consist of 10 nodes 1 edge node and 1 control center. I want to send data from nodes to the edge node.I have created a simulation environment for IoT network which consist of 10 nodes 1 edge node and 1 control center. I want to send data from nodes to the edge node. I have created a simulation environment for IoT network which consist of 10 nodes 1 edge node and 1 control center. I want to send data from nodes to the edge node. matlab, iot, nodes, iot network MATLAB Answers — New Questions