Category: News
how to find the accuracy from the predicted labels for test data in Matlab?
I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this.I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this. I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this. calculate test data accuracy MATLAB Answers — New Questions
Precision issue when comparing matlab output with c code output
I am trying to compare my c code output with matlab output. My results are matching up to 18th decimal points. When both matlab and c compiler uses ieee754 floating point format. Then why am I observing the difference. As matlab by default uses double precision, my c code is also using double data type.I am trying to compare my c code output with matlab output. My results are matching up to 18th decimal points. When both matlab and c compiler uses ieee754 floating point format. Then why am I observing the difference. As matlab by default uses double precision, my c code is also using double data type. I am trying to compare my c code output with matlab output. My results are matching up to 18th decimal points. When both matlab and c compiler uses ieee754 floating point format. Then why am I observing the difference. As matlab by default uses double precision, my c code is also using double data type. ieee754, precision, accuracy MATLAB Answers — New Questions
How to Stop People Using ChatGPT with OneDrive for Business Files
Block ChatGPT Access to OneDrive Files
ChatGPT allows people to connect their personal and work OneDrive accounts. Connecting to OneDrive doesn’t mean that ChatGPT can reason over OneDrive files in the same way that Microsoft 365 Copilot can when it generates responses. However, it does mean that users can upload files from OneDrive to interact with their content through ChatGPT. Figure 1 shows ChatGPT summarizes the content of a file uploaded from OneDrive for Business.

Of course, people shouldn’t store very confidential and sensitive information in OneDrive for Business accounts, but they do. And the temptation to use ChatGPT is obvious when the price of a Microsoft 365 Copilot license is high, so what can organizations do to stop this behavior.
ChatGPT Cannot Access Protected Files
One way to block ChatGPT access to OneDrive for Business is to encrypt the files with sensitivity labels. ChatGPT cannot process these files even after the owner of the file uploads them to ChatGPT. Sensitivity label encryption is based on rights management, and ChatGPT cannot authenticate with the rights management service to obtain the use license necessary to access files protected with sensitivity labels. That’s a pretty effective way to stop ChatGPT opening the file to copy its contents into memory to reason over the data. Microsoft 365 Copilot Chat faces much the same barrier if the sensitivity label assigned to a file doesn’t grant the EXTRACT usage right to the signed-in user (the new DLP policy for Microsoft 365 Copilot also uses sensitivity labels but blocks access in a different way).
Block Consent for Users
Not every Microsoft 365 tenant uses sensitivity labels, and even users in tenants that do don’t always protect files the way that they should. A more fundamental way to block ChatGPT access to OneDrive is to prevent users from being able to grant consent for apps (Figure 2). Make sure to select the “do not allow user consent” setting or allow consent for “low impact” apps.

If users can grant consent, the first user who attempts to connect their OneDrive for Business account to ChatGPT will create an enterprise app in Entra ID for ChatGPT with permissions to read user data (Figure 3).

This isn’t an abnormal situation because many app publishers (including Microsoft) create enterprise apps in customer tenants in the same way. However, it’s better to have administrative oversight over requests to create new enterprise apps. When created, the ChatGPT app will have a service principal to hold its permissions. The same application identifier (e0476654-c1d5-430b-ab80-70cbd947616a) is used in all tenants.
$ChatGPTApp = Get-MgServicePrincipal -Filter "displayName eq 'ChatGPT'" $ChatGPTApp DisplayName Id AppId SignInAudience ServicePrincipalType ----------- -- ----- -------------- -------------------- ChatGPT db277364-71ae-4fa4-9b02-370699b75a0a e0476654-c1d5-430b-ab80-70cbd947616a AzureADandPersonalMicrosoftAccount Application
App consent events are captured in the audit log and can be checked there.
Track What’s Happening
If the ChatGPT app exists in a tenant, it’s easy to check if anyone is using it by looking for sign-in events in the Entra ID log. Here’s some PowerShell to check the sign-in logs for anyone using the ChatGPT application:
[array]$Logs = Get-MgAuditLogSignIn -Filter "AppDisplayName eq 'ChatGPT'" -All $Logs | Group-Object UserDisplayName | Sort-Object Count -Descending | Format-Table Name, Count Name Count ---- ----- Kim Akers (She/Her) 5 René Artois 4
A more precise version checks for successful sign-ins using the ChatGPT application:
[array]$Logs = Get-MgAuditLogSignIn -Filter "AppDisplayName eq 'ChatGPT' and status/errorCode eq 0" -All
Remove the ChatGPT App
If the ChatGPT app is in use, the easiest way to block ChatGPT access to OneDrive for Business is to remove the service principal for its app:
Remove-MgServicePrincipal -ServicePrincipalId $ChatGPTApp.id
Access won’t terminate immediately because ChatGPT sessions might have obtained access tokens that are still valid, but once those tokens expire (within an hour), ChatGPT won’t be able to authenticate with Entra ID because the enterprise app is no longer present in the tenant. Anyone wanting to use ChatGPT to access OneDrive for Business files after that point will need to seek consent to use the app again. And by now, you’ll have blocked that route!
Insight like this doesn’t come easily. You’ve got to know the technology and understand how to look behind the scenes. Benefit from the knowledge and experience of the Office 365 for IT Pros team by subscribing to the best eBook covering Office 365 and the wider Microsoft 365 ecosystem.
C-Caller Block in Rapid Accelerator Mode with Busses
Is it possible to use the C-Caller in rapid accelerator mode when using buses?
When I include my structs as buses using `Simulink.importExternalCTypes`, I can’t run my simulation in rapid accelerator mode, because there is a name collision between my c code and the code generated by the rapid accelerator build process.
Renaming the structs in my code does not work, as then my c -caller blocks don’t recognize them as valid input/output dataformats.
This problem can be reproduced by using the C-Caller example "Call C Functions Using C Caller Block" (https://de.mathworks.com/help/releases/R2024b/simulink/slref/call-c-functions-using-c-caller-block.html).
When switching the example to rapid accelerator mode, the same problem occurs.Is it possible to use the C-Caller in rapid accelerator mode when using buses?
When I include my structs as buses using `Simulink.importExternalCTypes`, I can’t run my simulation in rapid accelerator mode, because there is a name collision between my c code and the code generated by the rapid accelerator build process.
Renaming the structs in my code does not work, as then my c -caller blocks don’t recognize them as valid input/output dataformats.
This problem can be reproduced by using the C-Caller example "Call C Functions Using C Caller Block" (https://de.mathworks.com/help/releases/R2024b/simulink/slref/call-c-functions-using-c-caller-block.html).
When switching the example to rapid accelerator mode, the same problem occurs. Is it possible to use the C-Caller in rapid accelerator mode when using buses?
When I include my structs as buses using `Simulink.importExternalCTypes`, I can’t run my simulation in rapid accelerator mode, because there is a name collision between my c code and the code generated by the rapid accelerator build process.
Renaming the structs in my code does not work, as then my c -caller blocks don’t recognize them as valid input/output dataformats.
This problem can be reproduced by using the C-Caller example "Call C Functions Using C Caller Block" (https://de.mathworks.com/help/releases/R2024b/simulink/slref/call-c-functions-using-c-caller-block.html).
When switching the example to rapid accelerator mode, the same problem occurs. c-code, c-caller, code-integration, rapid-accelerator, simulink, simulation MATLAB Answers — New Questions
How the Google-Wiz acquisition redefines cloud security
Google’s acquisition of Wiz, announced last week, is a pivotal moment as it marks a strategic shift in how cyber security will evolve over the next few years. It instantly turns Google into a major player in security, adding Wiz to other building blocks Google has racked up in the past couple of years, most notably Mandiant and Google Chronicle.
Google’s acquisition of Wiz, announced last week, is a pivotal moment as it marks a strategic shift in how cyber security will evolve over the next few years. It instantly turns Google into a major player in security, adding Wiz to other building blocks Google has racked up in the past couple of years, most notably Mandiant and Google Chronicle.
Read More
Microsoft at 50: The journey and future of the partner ecosystem
As we celebrate Microsoft’s 50th anniversary, our annual State of the Partner Ecosystem moment is a great opportunity to reflect on the incredible journey we’ve shared with our partners, employees and customers. Together, we’ve harnessed technology as a force for good, transforming industries and communities. From our early days of revolutionizing personal computing to leading the way in cloud innovation and now AI, our shared milestones highlight the power of collaboration and reinvention.
Fifty years ago, Microsoft started with a bold idea: the belief that technology could change the world. Thanks to the largest partner ecosystem in the industry, numbering 500,000 and growing, that vision became a reality, and I know we are just getting started. From the early days of distributing Windows PCs and Office to now delivering AI transformation strategies that solve the most complex customer challenges, our ability to stay at the forefront of innovation as technology evolves is a testament to our culture of continuous reinvention.
According to IDC, for every $1 of Microsoft revenue, services partners earn $8.45, and software partners earn $10.93. This underscores the immense opportunity available to partners of all types. As we look ahead to the future, we know that generative AI (GenAI) is forecast to grow exponentially faster than the overall IT market. Partners generating at least 25% of their Microsoft-related revenue from AI can expect higher margins and revenue growth, unlocking even more potential for transformation and success.*
Microsoft has always been a partner-led company. Our partners are core to our heritage and our future. Their innovation and collaboration have driven real transformation and customer success and will continue to shape the future of industries around the world. As we commemorate this historic moment, I want to take the opportunity to say Thank You to our partners for being on this incredible journey with us.
Here are just a few ways you can join us to celebrate this milestone:
- Watch this video from Judson Althoff, Executive Vice President and Chief Commercial Officer, Microsoft.
- Join the Microsoft AI Skills Fest for 50 days of learning and discovery starting April 8! Gain skills that will empower you and your team to build innovative AI solutions with Microsoft’s apps and services.
“For decades, Intel’s partnership with Microsoft has sparked innovation and delivered value to our customers. Together, we’ve revolutionized industries and established new benchmarks for excellence. We look forward to collaborating for the next 50 years — and beyond.”
— Jim Johnson, Senior Vice President, Client Computing Group, Intel
Preparing for the future with the Microsoft AI Cloud Partner Program (MAICPP)
Microsoft succeeds when our partners succeed. MAICPP has evolved to enable partners worldwide to deliver customer outcomes across every industry, from small businesses to the largest enterprises. Our program is designed to provide our partners with the most relevant tools and resources they need to thrive in a rapidly changing market, and it serves as the home for all partner types.
“As a proud Microsoft alum, I’ve seen firsthand how our collaboration has evolved to drive meaningful change for businesses across industries. From strategy through engineering and implementation, PwC and Microsoft drive innovation and deliver real business outcomes for clients worldwide.”
— Stephanie Mosticchio, Principal, US and Global Microsoft Alliance Leader, PwC
Through MAICPP, all partners can access updated benefits packages designed to accelerate growth and meet specific business needs. Software development companies are encouraged to explore ISV Success, a pathway offering additional benefits to expand development capabilities and shorten time to market. Whether building, publishing or growing sales, partners can leverage targeted offers to get the support they need.
“As someone who has led global partnerships at several of the world’s leading technology companies, I am impressed by how Microsoft has leaned in with their partner ecosystem and taken a leadership position in cloud computing and AI. We, at Snowflake, are excited to continue to strengthen our partnership in the years to come, and we look forward to jointly driving customer success in the age of enterprise AI. Congratulations!
— Tyler Prince, Senior Vice President of Worldwide Alliances & Channels, Snowflake
Depending on business goals, partners may pursue a Solutions Partner designation or specialization, both of which provide tailored benefits to help differentiate their business in a competitive market. Achieving a designation unlocks valuable go-to-market resources, sales support, new incentives and product benefits to help expand customer reach, sharpen skills and drive growth. For software development companies, becoming a Solutions Partner** with certified software*** further enhances market presence by validating software capabilities in high-demand areas.
“Having worked alongside every CEO of Microsoft in my career, I would like to personally congratulate Microsoft for its 50 extraordinary years of driving relentless innovation.”
“Lenovo is proud to be a major part of this amazing journey with Microsoft and we are committed to this partnership for many more decades to come.”
— Yuanqing Yang, Chairman and Chief Executive Officer, Lenovo
For partners holding an Azure designation or Azure specialization, additional incentives are available through Azure Migrate and Modernize and Azure Innovate — both underpinned by Azure Essentials. With comprehensive resources, extensive coverage across scenarios and tailored incentives in one easy-to-navigate hub, Azure partners can better support customers from migration to innovation. Learn more in What’s new for Azure partner-led offerings: ISV Success and specialization updates.
Our program offers benefits for partners aligned to their growth stage and across all customer segments. We have recently made the process of obtaining an Azure Solutions Partner designation more aligned to our partners who specialize in working with small and midsize customers. We are also expanding access to Azure Migrate and Modernize and Azure Innovate incentives for SMB pathways. Read more about the SMB path to Azure Solutions Partner designations.
Cloud Solution Provider is our partner hero motion for small and medium enterprises
In November at Microsoft Ignite, we highlighted the $661 billion total addressable market (TAM) opportunity for SME&C customers in FY25 and beyond. Cloud Solution Provider (CSP) partners are the trusted advisors who serve these customers and accelerate their AI transformation with the value-added services and solutions that create real business impact. CSP is our hero motion that enables those partners to drive this business transformation.
“Our Microsoft partnership has evolved to meet the needs of our business and our partners. Together we’ve been able to support our partners to deliver true solution and value selling, leveraging the robust resources available through Microsoft AI Cloud Partner Program and benefitting from the rich incentives. It has enabled us to drive innovation and deliver exceptional experiences for our partners through our ArrowSphere platform and broader enablement programs to ensure they’re empowered to deliver real customer outcomes. Together, we’re enabling the channel to deliver solutions that deliver real impact for customers around the world.”
— Brendan Murphy, Global Director, Public Cloud, Arrow Electronics
We strive to provide CSP partners with the skilling, capabilities and investments to make this opportunity a reality. So far in FY25, we have:
- focused our incentives to clearly align to our five strategic priorities — Copilot on every device across every role, AI design wins with every customer, securing the cyber foundation of every customer, a focus on migrations and Microsoft 365 execution
- dedicated 70% of our total incentive spend to partners that serve the Small and Medium Enterprise and Customer (SME&C) segment
- introduced a series of new promos, including a new-to-Microsoft 365 E5 offer to enable CSP partners to win new customers
Expanding our portfolio of CSP offers and capabilities is an ongoing priority. We share updates as they become available.
Capturing the marketplace opportunity
As customers increasingly centralize their solution procurement, marketplaces have become the preferred buying platform. For software companies, adopting cloud marketplaces accelerates deal closure and increases deal sizes. Serving as a global B2B commerce engine, our marketplace empowers Microsoft partners to provide solutions to customers worldwide. It offers various sales models: digital direct, through partners or with Microsoft — providing flexibility to align with how customers want to buy and how partners want to sell. Learn more in this recent blog.
Unlocking success through skilling and events
The speed of technology innovation requires continuous learning. To support this, we offer our partners a variety of skilling opportunities, such as our popular in-person Microsoft AI Partner Training Days, designed to help partners develop both technical and sales capabilities.
We are also streamlining and simplifying our skilling portals through initiatives like Microsoft Sales Titan (currently in private preview for CSP Accelerate partners and available for all partners in summer 2025), a program tailored to equip sales professionals with in-depth knowledge of Microsoft Threat Protection SKUs, empowering them to position themselves as industry leaders. Discover these and other skilling opportunities.
Looking ahead, we invite our partners to join us at Microsoft Build, taking place May 19–22, 2025. This flagship event offers an exclusive opportunity to explore the latest advancements in AI, learn how to work smarter and elevate your projects. Connect with peers, industry experts and Microsoft leadership while diving into the code and innovations that will shape the future.
“Schneider Electric and Microsoft have been driven by a shared vision of a world that is more electric and digital. We’re thrilled to celebrate Microsoft’s 50th anniversary and excited to continue pioneering innovative solutions together, harnessing the transformative power of AI, pushing the boundaries of what’s possible for our customers and shaping a sustainable future for generations to come.”
— Frédéric Godemel, Executive Vice President, Energy Management, Schneider Electric
Looking forward – the next 50 years
As we celebrate this remarkable milestone, we remain focused on and optimistic for the future. We continue to innovate, collaborate and empower our partners to thrive in the era of AI and beyond. The past 50 years have been defined by shared success, and this will continue for our future. Together, we will unlock new opportunities, drive transformation and shape the future of technology.
Throughout this journey, stories of innovation have inspired us. A few examples of how partners are celebrating our 50th anniversary are included in this blog. See the full list of partner quotes on the Microsoft 50th Anniversary celebration site.
Thank you for being an integral part of our story. We can’t wait to see what we’ll accomplish together next!
*IDC: Microsoft Partners: Driving Economic Value and AI Maturity
**“Solutions Partner” refers to a company that is a member of the Microsoft AI Cloud Partner Program and may offer software, services, and/or solutions to customers. Reference to “Solutions Partner” in any content, materials, resources, web properties, etc. and any associated designation should be not interpreted as an offer, endorsement, guarantee, proof of effectiveness or functionality, a commitment or any other type of representation or warranty on the part of Microsoft. All decisions pertaining to and related to your business needs including but not limited to strategies, solutions, partner selection, implementation, etc. rest solely with your business.
***A certification is (A) specific to the solution’s interoperability with Microsoft products and (B) based on self-attestation by the solution owner. Solutions are only certified as of the date the solution is reviewed. Solution functionality and capability are controlled by the solution owner and may be subject to change. The inclusion of a solution in marketplace and any such designations should not be interpreted as an offer, endorsement, guarantee, proof of effectiveness or functionality, a commitment or any other type of representation or warranty on the part of Microsoft. All decisions pertaining and related to your business needs including but not limited to strategies, solutions, partner selection, implementation, etc. rest solely with your business.
The post Microsoft at 50: The journey and future of the partner ecosystem appeared first on The Official Microsoft Blog.
As we celebrate Microsoft’s 50th anniversary, our annual State of the Partner Ecosystem moment is a great opportunity to reflect on the incredible journey we’ve shared with our partners, employees and customers. Together, we’ve harnessed technology as a force for good, transforming industries and communities. From our early days of revolutionizing personal computing to leading…
The post Microsoft at 50: The journey and future of the partner ecosystem appeared first on The Official Microsoft Blog.Read More
Why this error is occuring while deploying in ROS2?
Hey all, I am trying to deploy in a ROS2 device from Simulink. I keep facing this error. FYI, the device being deployed in is Intel Nuc. It is being deployed through Wi-Fi. I also deployed in another ROS2 machine without any error therefore the Simulink model has no error by design. Please don’t hesitate to ask for further information. Glad to provide to solve the issue.Hey all, I am trying to deploy in a ROS2 device from Simulink. I keep facing this error. FYI, the device being deployed in is Intel Nuc. It is being deployed through Wi-Fi. I also deployed in another ROS2 machine without any error therefore the Simulink model has no error by design. Please don’t hesitate to ask for further information. Glad to provide to solve the issue. Hey all, I am trying to deploy in a ROS2 device from Simulink. I keep facing this error. FYI, the device being deployed in is Intel Nuc. It is being deployed through Wi-Fi. I also deployed in another ROS2 machine without any error therefore the Simulink model has no error by design. Please don’t hesitate to ask for further information. Glad to provide to solve the issue. ros2, simulink MATLAB Answers — New Questions
When I import a Creo model to Simscape Multibody, some of my reference frames are not being imported. Is there something I need to do in Creo or in Simscape?
I have imported a Creo model via the multibody link to Simscape. When I open the model in Mechanics Explorer, the model itself has been imported correctly, but not all the reference frames are imported (I set reference frames at the desired locations in Creo). I want my reference point at a specific location on my model so that I can measure the position (x, y, z). How can I ensure that all reference frames are imported correctly and set a reference point at a specific location?I have imported a Creo model via the multibody link to Simscape. When I open the model in Mechanics Explorer, the model itself has been imported correctly, but not all the reference frames are imported (I set reference frames at the desired locations in Creo). I want my reference point at a specific location on my model so that I can measure the position (x, y, z). How can I ensure that all reference frames are imported correctly and set a reference point at a specific location? I have imported a Creo model via the multibody link to Simscape. When I open the model in Mechanics Explorer, the model itself has been imported correctly, but not all the reference frames are imported (I set reference frames at the desired locations in Creo). I want my reference point at a specific location on my model so that I can measure the position (x, y, z). How can I ensure that all reference frames are imported correctly and set a reference point at a specific location? multibody link MATLAB Answers — New Questions
How to perform definite integration with non-commutable symbolic coefficients?
Hi All,
I am trying to perform a definite integration in X (length axis) to calculate some beam modeshapes, following this the variables will be passed into a time integration using ode45. In the integration there are beam modeshape terms (W) which are a function of x and there are time dependent terms (qw) which are not. Crucially the qw terms are not commutable so cannot be factored out of the integrals. I need the answer to W6 to be given in terms W6=Y1*qw1+Y2*qw2… where Y1 and Y2 are numerical coefficients.
Here is my code:
clear all
clc
syms x qw1 qw2
L=0.52;
qw=[qw1; qw2];
%Bending Mode
Landa=[1.875104069 4.694091133];% 7.854757];% 10.99554];
for j=1:length(Landa)
SIGMA(j)=(cos(Landa(j))+cosh(Landa(j)))/(sin(Landa(j))+sinh(Landa(j)));
W(j)=cosh(Landa(j)*x/L)-cos(Landa(j)*x/L)-SIGMA(j)*(sinh(Landa(j)*x/L)-sin(Landa(j)*x/L));
end
% Integration in X over length of beam
W6=(vpaintegral(W*diff(diff(W,x,1)*qw*diff(diff(W,x,1)*qw*diff(W,x,2)*qw,x,1),x,1),0,L));
The value W6 is left as symbolic without the integrals being solved, this means that when I pass the W6 term into the time integration in a separate script and solve for qw terms the time integration is much slower because it is computing the spatial integration in X for each time of the 1000 time-steps.
I have tried using the ‘double’,’simplify’ and ‘collect’ commands but I have not been able to get the result in the form I want it. So what I’m asking is, is there a way to "force" matlab to do the integrations with the symbolic coefficients attahced. Any help would be much appreciated!Hi All,
I am trying to perform a definite integration in X (length axis) to calculate some beam modeshapes, following this the variables will be passed into a time integration using ode45. In the integration there are beam modeshape terms (W) which are a function of x and there are time dependent terms (qw) which are not. Crucially the qw terms are not commutable so cannot be factored out of the integrals. I need the answer to W6 to be given in terms W6=Y1*qw1+Y2*qw2… where Y1 and Y2 are numerical coefficients.
Here is my code:
clear all
clc
syms x qw1 qw2
L=0.52;
qw=[qw1; qw2];
%Bending Mode
Landa=[1.875104069 4.694091133];% 7.854757];% 10.99554];
for j=1:length(Landa)
SIGMA(j)=(cos(Landa(j))+cosh(Landa(j)))/(sin(Landa(j))+sinh(Landa(j)));
W(j)=cosh(Landa(j)*x/L)-cos(Landa(j)*x/L)-SIGMA(j)*(sinh(Landa(j)*x/L)-sin(Landa(j)*x/L));
end
% Integration in X over length of beam
W6=(vpaintegral(W*diff(diff(W,x,1)*qw*diff(diff(W,x,1)*qw*diff(W,x,2)*qw,x,1),x,1),0,L));
The value W6 is left as symbolic without the integrals being solved, this means that when I pass the W6 term into the time integration in a separate script and solve for qw terms the time integration is much slower because it is computing the spatial integration in X for each time of the 1000 time-steps.
I have tried using the ‘double’,’simplify’ and ‘collect’ commands but I have not been able to get the result in the form I want it. So what I’m asking is, is there a way to "force" matlab to do the integrations with the symbolic coefficients attahced. Any help would be much appreciated! Hi All,
I am trying to perform a definite integration in X (length axis) to calculate some beam modeshapes, following this the variables will be passed into a time integration using ode45. In the integration there are beam modeshape terms (W) which are a function of x and there are time dependent terms (qw) which are not. Crucially the qw terms are not commutable so cannot be factored out of the integrals. I need the answer to W6 to be given in terms W6=Y1*qw1+Y2*qw2… where Y1 and Y2 are numerical coefficients.
Here is my code:
clear all
clc
syms x qw1 qw2
L=0.52;
qw=[qw1; qw2];
%Bending Mode
Landa=[1.875104069 4.694091133];% 7.854757];% 10.99554];
for j=1:length(Landa)
SIGMA(j)=(cos(Landa(j))+cosh(Landa(j)))/(sin(Landa(j))+sinh(Landa(j)));
W(j)=cosh(Landa(j)*x/L)-cos(Landa(j)*x/L)-SIGMA(j)*(sinh(Landa(j)*x/L)-sin(Landa(j)*x/L));
end
% Integration in X over length of beam
W6=(vpaintegral(W*diff(diff(W,x,1)*qw*diff(diff(W,x,1)*qw*diff(W,x,2)*qw,x,1),x,1),0,L));
The value W6 is left as symbolic without the integrals being solved, this means that when I pass the W6 term into the time integration in a separate script and solve for qw terms the time integration is much slower because it is computing the spatial integration in X for each time of the 1000 time-steps.
I have tried using the ‘double’,’simplify’ and ‘collect’ commands but I have not been able to get the result in the form I want it. So what I’m asking is, is there a way to "force" matlab to do the integrations with the symbolic coefficients attahced. Any help would be much appreciated! definite integration, symbolic toolbox, simplifying MATLAB Answers — New Questions
Non-linear scaling for linear increase in complexity
I have a class which defines an array and then loops over this array updating each element in turn. If I change the length of the array linearly the runtime increases non-linearly. Why? I must be missing something silly.
classdef C
properties
N uint32 {mustBeInteger, mustBePositive}
x (1, {mustBeFloat, mustBeNonnegative} = []
end
methods
function c = C(N)
arguments
N uint32 {mustBeInteger, mustBePositive}
end
c.N = N;
c.x = zeros(1, c.N);
end
function run(c)
arguments
c C
end
for i = 1:c.N
c.x(i) = 1;
end
end
end
end
N_range = 1e4:1e4:1e5;
times = zeros(1, length(N_range));
N_i = 1;
for N = N_range
c = C(N);
tic
c.run();
times(N_i) = toc;
N_i = N_i + 1;
end
plot(times)I have a class which defines an array and then loops over this array updating each element in turn. If I change the length of the array linearly the runtime increases non-linearly. Why? I must be missing something silly.
classdef C
properties
N uint32 {mustBeInteger, mustBePositive}
x (1, {mustBeFloat, mustBeNonnegative} = []
end
methods
function c = C(N)
arguments
N uint32 {mustBeInteger, mustBePositive}
end
c.N = N;
c.x = zeros(1, c.N);
end
function run(c)
arguments
c C
end
for i = 1:c.N
c.x(i) = 1;
end
end
end
end
N_range = 1e4:1e4:1e5;
times = zeros(1, length(N_range));
N_i = 1;
for N = N_range
c = C(N);
tic
c.run();
times(N_i) = toc;
N_i = N_i + 1;
end
plot(times) I have a class which defines an array and then loops over this array updating each element in turn. If I change the length of the array linearly the runtime increases non-linearly. Why? I must be missing something silly.
classdef C
properties
N uint32 {mustBeInteger, mustBePositive}
x (1, {mustBeFloat, mustBeNonnegative} = []
end
methods
function c = C(N)
arguments
N uint32 {mustBeInteger, mustBePositive}
end
c.N = N;
c.x = zeros(1, c.N);
end
function run(c)
arguments
c C
end
for i = 1:c.N
c.x(i) = 1;
end
end
end
end
N_range = 1e4:1e4:1e5;
times = zeros(1, length(N_range));
N_i = 1;
for N = N_range
c = C(N);
tic
c.run();
times(N_i) = toc;
N_i = N_i + 1;
end
plot(times) complexity, validation, overhead, speed, performance MATLAB Answers — New Questions
I have this system of linear equations and i need to solve it for unknowns. how i can solve it in MATLAB? we have 8 unknowns and 8 equations.
$$
begin{aligned}
& b_{0}^{l}=a_{0}^{l} A_{00}^{l}+sum_{n=a_{n}}^{infty} a_{n}^{l} A_{0} n^{ell}+Z_{0}^{l} \
& b_{m}^{l}=a_{0}^{l} A_{m 0}^{l}+sum_{n=1}^{infty} a_{n}^{l} A_{m n}^{l}+Z_{m}^{l} \
& a_{0}^{l}=b_{0}^{l} B_{00}^{l}+sum_{m=1}^{infty} b_{m}{ }^{l} B_{0 m}^{l}+c_{0}^{l} C_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{0 m}^{l}+Y_{0}^{l} \
& a_{n}^{l}=b_{0}^{l} B_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} B_{n m}^{l}+c_{0}^{l} C_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{n m}^{l}+Y_{n}^{l}
end{aligned}
$$
and:
$$
begin{aligned}
& c_{0}^{l}=d_{0}^{l} D_{00}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{0 n}^{l}+X_{0}^{l} \
& c_{m}^{l}=d_{0}^{l} D_{m 0}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{m n}^{ell}+X_{m}^{ell} \
& d_{0}^{ell} = b_{0}^{l} E_{00}^{ell}+sum_{m=1}^{infty} b_{m}^{ell} E_{0 m}^{l}+c_{0}^{l} F_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{0 m}^{l}+W_{0}^{l} \
& d_{n}^{l}=b_{0}^{l} E_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} E_{n m}^{l}+c_{0}^{l} F_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{n m}^{l}+W_{n}^{l}
end{aligned}
$$
Unknowns are:-
$$
begin{gathered}
left(a_{0}^{l}, a_{n}^{l}right) ;left(b_{0}^{l}, b_{n}^{l}right),left(c_{0}^{l}, c_{n}^{l}right) and \
left(d_{0}^{l}, d_{n}^{l}right) .
end{gathered}
$$
The above system of equations which is linear one is the latex code for these equations and i need to solve it for these unknowns. I am confused that how i can solved this system. how i can write these equations in matrix form to solved it for the unknowns? Help me.$$
begin{aligned}
& b_{0}^{l}=a_{0}^{l} A_{00}^{l}+sum_{n=a_{n}}^{infty} a_{n}^{l} A_{0} n^{ell}+Z_{0}^{l} \
& b_{m}^{l}=a_{0}^{l} A_{m 0}^{l}+sum_{n=1}^{infty} a_{n}^{l} A_{m n}^{l}+Z_{m}^{l} \
& a_{0}^{l}=b_{0}^{l} B_{00}^{l}+sum_{m=1}^{infty} b_{m}{ }^{l} B_{0 m}^{l}+c_{0}^{l} C_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{0 m}^{l}+Y_{0}^{l} \
& a_{n}^{l}=b_{0}^{l} B_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} B_{n m}^{l}+c_{0}^{l} C_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{n m}^{l}+Y_{n}^{l}
end{aligned}
$$
and:
$$
begin{aligned}
& c_{0}^{l}=d_{0}^{l} D_{00}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{0 n}^{l}+X_{0}^{l} \
& c_{m}^{l}=d_{0}^{l} D_{m 0}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{m n}^{ell}+X_{m}^{ell} \
& d_{0}^{ell} = b_{0}^{l} E_{00}^{ell}+sum_{m=1}^{infty} b_{m}^{ell} E_{0 m}^{l}+c_{0}^{l} F_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{0 m}^{l}+W_{0}^{l} \
& d_{n}^{l}=b_{0}^{l} E_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} E_{n m}^{l}+c_{0}^{l} F_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{n m}^{l}+W_{n}^{l}
end{aligned}
$$
Unknowns are:-
$$
begin{gathered}
left(a_{0}^{l}, a_{n}^{l}right) ;left(b_{0}^{l}, b_{n}^{l}right),left(c_{0}^{l}, c_{n}^{l}right) and \
left(d_{0}^{l}, d_{n}^{l}right) .
end{gathered}
$$
The above system of equations which is linear one is the latex code for these equations and i need to solve it for these unknowns. I am confused that how i can solved this system. how i can write these equations in matrix form to solved it for the unknowns? Help me. $$
begin{aligned}
& b_{0}^{l}=a_{0}^{l} A_{00}^{l}+sum_{n=a_{n}}^{infty} a_{n}^{l} A_{0} n^{ell}+Z_{0}^{l} \
& b_{m}^{l}=a_{0}^{l} A_{m 0}^{l}+sum_{n=1}^{infty} a_{n}^{l} A_{m n}^{l}+Z_{m}^{l} \
& a_{0}^{l}=b_{0}^{l} B_{00}^{l}+sum_{m=1}^{infty} b_{m}{ }^{l} B_{0 m}^{l}+c_{0}^{l} C_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{0 m}^{l}+Y_{0}^{l} \
& a_{n}^{l}=b_{0}^{l} B_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} B_{n m}^{l}+c_{0}^{l} C_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} C_{n m}^{l}+Y_{n}^{l}
end{aligned}
$$
and:
$$
begin{aligned}
& c_{0}^{l}=d_{0}^{l} D_{00}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{0 n}^{l}+X_{0}^{l} \
& c_{m}^{l}=d_{0}^{l} D_{m 0}^{ell}+sum_{n=1}^{infty} d_{n}^{l} D_{m n}^{ell}+X_{m}^{ell} \
& d_{0}^{ell} = b_{0}^{l} E_{00}^{ell}+sum_{m=1}^{infty} b_{m}^{ell} E_{0 m}^{l}+c_{0}^{l} F_{00}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{0 m}^{l}+W_{0}^{l} \
& d_{n}^{l}=b_{0}^{l} E_{n 0}^{l}+sum_{m=1}^{infty} b_{m}^{l} E_{n m}^{l}+c_{0}^{l} F_{n 0}^{l}+sum_{m=1}^{infty} c_{m}^{l} F_{n m}^{l}+W_{n}^{l}
end{aligned}
$$
Unknowns are:-
$$
begin{gathered}
left(a_{0}^{l}, a_{n}^{l}right) ;left(b_{0}^{l}, b_{n}^{l}right),left(c_{0}^{l}, c_{n}^{l}right) and \
left(d_{0}^{l}, d_{n}^{l}right) .
end{gathered}
$$
The above system of equations which is linear one is the latex code for these equations and i need to solve it for these unknowns. I am confused that how i can solved this system. how i can write these equations in matrix form to solved it for the unknowns? Help me. system of equations MATLAB Answers — New Questions
Why Teams Clients Prompt for Your Location
Location Privacy Setting for Teams is Now Separate to Windows
If you wonder why Teams has suddenly started to prompt for approval to use your precise location and location history when you sign into a client, the answer lies in message center notification MC993226 (last updated 7 March 2025). It’s all to do with an update to Microsoft privacy policies governing how apps can use location information. Microsoft refers to this as a “location consent experience” which applies to Windows (running version 24H2 or later) and Mac workstations, but not VDI clients.
Take the example shown in Figure 1. Teams knows that the location setting for the Windows PC permits location information to be shared with IT admins to help troubleshoot issues like network connectivity (Figure 2). Until the change became effective, Teams used the Windows setting, but now Teams has its setting to govern whether it can access location data.


VDI desktops obviously don’t support the same level of precision when it comes to location data, which is why they’re currently excluded from location privacy. For more information about how to manage location sharing in Teams, see the Microsoft support documentation.
Targeted release has started, and general availability is slated for deployment between late March and early April 2025. The update will be available in the commercial and government clouds. Microsoft notes that the new location privacy consent “does not apply to fully managed devices where users are restricted from user granted location access” and that current policies will continue working as before.
Location Privacy is a Per Tenant Choice
Teams displays the location notice for each tenant accessed during a client session. For instance, if you switch from your home tenant to a tenant where you’re a guest member, Teams displays the location notice again. The reason is that the location information gathered by Teams is provided on a tenant basis, so the notice acts as a prompt for the user to disable the information in the Privacy section of the Teams settings app (Figure 3).

Location Data for Teams
MC993226 says that Teams is specifically interested in the SSID and BSSID. The SSID (service set identifier or network name) is the identifier for a Wi-Fi network. The BSSID (Basic service set identifier) is the MAC address of the network access point or Wi-Fi router used by a device to connect to a network.
Teams uses this information for the Call Quality Dashboard to track call quality at the organization level. Knowing someone’s location is also critical for location-based call routing to work. The data is also used for dynamic emergency calling in Teams Phone to allow the location of emergency calls to be identified. If your organization doesn’t have a Teams Phone subscription and a calling plan, you won’t have access to emergency calling. On the surface, if you don’t use Teams Phone, it seems like you don’t need to worry about location privacy.
Microsoft hasn’t given a firm number for Teams Phone users since July 2021 when they said that 80 million people used Teams Phone. However, although Microsoft has been nudging customers to use Teams Phone for years, the reported number doesn’t say how many users have paid calling plans instead of just using Teams Phone for VOIP calls.
Location Privacy is Important
Obviously, Microsoft would like users to consent to sharing location data with Teams as otherwise features won’t work as designed. I don’t think that anyone will complain too much about location data being shared with Teams to measure the quality of calls or to know where someone is when they make an emergency call. Using location data for other purposes, such as knowing the hot desk that someone is working at might be another matter, which is why keeping an eye on location privacy is important.
Learn how to exploit the data available to Microsoft 365 tenant administrators through the Office 365 for IT Pros eBook. We love figuring out how things work.
How can i change rotation axis?
Rotation axis normally defined axis around Z,I want to rotate my modal around x and y axis how can i change rotation axis of the revolute joint?
ThanksRotation axis normally defined axis around Z,I want to rotate my modal around x and y axis how can i change rotation axis of the revolute joint?
Thanks Rotation axis normally defined axis around Z,I want to rotate my modal around x and y axis how can i change rotation axis of the revolute joint?
Thanks rotation, axis, simmechanics MATLAB Answers — New Questions
How do I find the number of circles in an image? I’ve given the code I used and output image below
clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS);clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS); clc;
close all;
clear all;
a=imread(‘C:UsersHemaDesktopnonemptylot.jpg’);
b=imread(‘C:UsersHemaDesktopemptylot.jpg’);
[x,y]= size(a);
[c d]=size(b);
e=rgb2hsv(a);
f=rgb2hsv(b);
subplot(1,2,1)
imshow(e);
title(‘HSV of Nonempty’);
centers = imfindcircles(e,[20 20]);
[centers,radii] = imfindcircles(e,[5 15]);
[centers,radii,metric] = imfindcircles(e,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
subplot(1,2,2)
imshow(f);
title(‘HSV of empty’);
centers = imfindcircles(f,[20 20]);
[centers,radii] = imfindcircles(f,[5 15]);
[centers,radii,metric] = imfindcircles(f,[5 15]);
BW=size(viscircles(centers, radii,’EdgeColor’,’b’));
STATS = regionprops(BW,’EquivDiameter’);
disp(STATS); circles, finding number of objects, image processing MATLAB Answers — New Questions
How to put a legend outside of a tiled layout graph?
I am trying to create some graphs, and I am struggling to put the legend where I want it in my graph. I would like my graph to look like this:
However, the code that i have wrtiien:
%%% plot mean and SD:
s = sprintf(‘[%c]’, char(176)); % degree angle symbol
figure
title(‘Mean and SD’)
ax1=subplot(4,1,1);
fontsize=get(ax1, ‘FontSize’);
title(‘Start’)
hold on
[m,n] = size(DATA1start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1start’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2start’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3start’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1start’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2start’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3start’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
% Create fake points for the legend
hFakeDATA1 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#228b22", ‘MarkerEdgeColor’, "#228b22", ‘MarkerSize’, 5);
hFakeDATA2 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#395dc7", ‘MarkerEdgeColor’, "#395dc7", ‘MarkerSize’, 5);
hFakeDATA3 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#f88f09", ‘MarkerEdgeColor’, "#f88f09", ‘MarkerSize’, 5);
% Create fake entry for the shaded region
hShadedRegion = plot(NaN, NaN, ‘s’, ‘MarkerFaceColor’, [0.7 0.7 0.7], ‘MarkerEdgeColor’, ‘none’, ‘MarkerSize’, 8);
% Create custom legend with the fake points
legend([hFakeDATA1, hFakeDATA2, hFakeDATA3, hShadedRegion], …
{‘DATA1’, ‘DATA2’, ‘DATA3’, ‘Main effect of group’}, ‘Location’, ‘bestoutside’);
subplot(4,1,2)
title(‘Middle’)
hold on
[m,n] = size(DATA1middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1middle’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2middle’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3middle’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1middle’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2middle’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3middle’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
subplot(4,1,3)
title(‘End’)
hold on
[m,n] = size(DATA1last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1last’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2last’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3last’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1last’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2last’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3last’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
Provides me with the graph shown here. I can’t seem to put the legend in the correct place ( I have moved the block of code around to create the legend before and after each graph, but with no success). I would like the legend to be outside of all the tiles! Any advice would be much appreciated :)I am trying to create some graphs, and I am struggling to put the legend where I want it in my graph. I would like my graph to look like this:
However, the code that i have wrtiien:
%%% plot mean and SD:
s = sprintf(‘[%c]’, char(176)); % degree angle symbol
figure
title(‘Mean and SD’)
ax1=subplot(4,1,1);
fontsize=get(ax1, ‘FontSize’);
title(‘Start’)
hold on
[m,n] = size(DATA1start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1start’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2start’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3start’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1start’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2start’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3start’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
% Create fake points for the legend
hFakeDATA1 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#228b22", ‘MarkerEdgeColor’, "#228b22", ‘MarkerSize’, 5);
hFakeDATA2 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#395dc7", ‘MarkerEdgeColor’, "#395dc7", ‘MarkerSize’, 5);
hFakeDATA3 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#f88f09", ‘MarkerEdgeColor’, "#f88f09", ‘MarkerSize’, 5);
% Create fake entry for the shaded region
hShadedRegion = plot(NaN, NaN, ‘s’, ‘MarkerFaceColor’, [0.7 0.7 0.7], ‘MarkerEdgeColor’, ‘none’, ‘MarkerSize’, 8);
% Create custom legend with the fake points
legend([hFakeDATA1, hFakeDATA2, hFakeDATA3, hShadedRegion], …
{‘DATA1’, ‘DATA2’, ‘DATA3’, ‘Main effect of group’}, ‘Location’, ‘bestoutside’);
subplot(4,1,2)
title(‘Middle’)
hold on
[m,n] = size(DATA1middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1middle’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2middle’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3middle’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1middle’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2middle’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3middle’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
subplot(4,1,3)
title(‘End’)
hold on
[m,n] = size(DATA1last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1last’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2last’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3last’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1last’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2last’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3last’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
Provides me with the graph shown here. I can’t seem to put the legend in the correct place ( I have moved the block of code around to create the legend before and after each graph, but with no success). I would like the legend to be outside of all the tiles! Any advice would be much appreciated I am trying to create some graphs, and I am struggling to put the legend where I want it in my graph. I would like my graph to look like this:
However, the code that i have wrtiien:
%%% plot mean and SD:
s = sprintf(‘[%c]’, char(176)); % degree angle symbol
figure
title(‘Mean and SD’)
ax1=subplot(4,1,1);
fontsize=get(ax1, ‘FontSize’);
title(‘Start’)
hold on
[m,n] = size(DATA1start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1start’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2start’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3start);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3start’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1start’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2start’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3start’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
% Create fake points for the legend
hFakeDATA1 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#228b22", ‘MarkerEdgeColor’, "#228b22", ‘MarkerSize’, 5);
hFakeDATA2 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#395dc7", ‘MarkerEdgeColor’, "#395dc7", ‘MarkerSize’, 5);
hFakeDATA3 = plot(NaN, NaN, ‘o’, ‘MarkerFaceColor’, "#f88f09", ‘MarkerEdgeColor’, "#f88f09", ‘MarkerSize’, 5);
% Create fake entry for the shaded region
hShadedRegion = plot(NaN, NaN, ‘s’, ‘MarkerFaceColor’, [0.7 0.7 0.7], ‘MarkerEdgeColor’, ‘none’, ‘MarkerSize’, 8);
% Create custom legend with the fake points
legend([hFakeDATA1, hFakeDATA2, hFakeDATA3, hShadedRegion], …
{‘DATA1’, ‘DATA2’, ‘DATA3’, ‘Main effect of group’}, ‘Location’, ‘bestoutside’);
subplot(4,1,2)
title(‘Middle’)
hold on
[m,n] = size(DATA1middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1middle’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2middle’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3middle);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3middle’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1middle’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2middle’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3middle’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
subplot(4,1,3)
title(‘End’)
hold on
[m,n] = size(DATA1last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA1last’,2,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
[m,n] = size(DATA2last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA2last’,2,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)%stdshade(DATA2start’,’0.3′,’b’)
hold on
[m,n] = size(DATA3last);
xaxis=repmat(1:101, n, 1);
scatter(xaxis,DATA3last’,2,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09", ‘MarkerFaceAlpha’,.3,’MarkerEdgeAlpha’,.3)
hold on
scatter(1:101,mean(DATA1last’,’omitnan’),10,’MarkerFaceColor’,"#228b22",’MarkerEdgeColor’,"#228b22")
hold on
scatter(1:101,mean(DATA2last’,’omitnan’),10,’MarkerFaceColor’,"#395dc7",’MarkerEdgeColor’,"#395dc7")
hold on
scatter(1:101,mean(DATA3last’,’omitnan’),10,’MarkerFaceColor’,"#f88f09",’MarkerEdgeColor’,"#f88f09")
ylabel([‘Angular Difference’, s])
xlabel([‘Percentage of gait cycle (%)’])
xlim([0 100])
ylim([0 60])
Provides me with the graph shown here. I can’t seem to put the legend in the correct place ( I have moved the block of code around to create the legend before and after each graph, but with no success). I would like the legend to be outside of all the tiles! Any advice would be much appreciated scatter, legend, tiledlayout, location, bestoutside MATLAB Answers — New Questions
how can I save a variable to an excel file?
Hi,
I have a complex variable (named "ST_normalized") in my MATLAB code. I want to save that file to an Excel file. Can you please help me with that? Thanks for your time.
regardsHi,
I have a complex variable (named "ST_normalized") in my MATLAB code. I want to save that file to an Excel file. Can you please help me with that? Thanks for your time.
regards Hi,
I have a complex variable (named "ST_normalized") in my MATLAB code. I want to save that file to an Excel file. Can you please help me with that? Thanks for your time.
regards matlab, figure, save, variable MATLAB Answers — New Questions
Optimization method based on the Nonlinear least squares as well as fmincon for the defined objective function (Non-linear function).
Hi there,
I am currently working on a Matlab code for my task (optimization task), and I tried two different methods;
Method A: the fmincon was used to minimize the objective function in which different algorithms, such as interior-point, sqp, sqp-legacy, interior-point, and active-set, were applied.
Method B: Nonlinear least squares optimization was combined with three algorithms, levenberg-marquardt, and trust-region-reflective.
The best results I got now are (from the Nonlinear least squares optimization + ‘interior-point’):
RMSE for X, Y, Z Direction(mm) : [1.18, 0.16, 1.33] mm; however, I want to reduce it as far as it is possible.
@ A quick guide for the code, and how it works.
1. I do have 3D data sets, and I used some mathematical methods to convert these 3D data into 2D data (Step 3).
2. The goal is to use some inverse method to get the same 3D datasets; therefore, after defining the objective function, I applied different optimization methods to address this task.
Any assistance or alternative approaches would be greatly appreciated.
Thank you in advance!
% @ Payam Samadi (2025.3.15) NLSP (Nonlinear least squares optimization)
% In step 3, the 2D projection data was extracted from the 3D data at
% different projections.
% In step4, the objective function is defined.
% In step 5, the Nonlinear least squares optimization is used to minimize
% the objective function.
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Note: It is important to carefully consider the initial guesses for
% target locations, as well as the lower bounds (lb) and upper bounds (ub).
tic;
clc;
clear;
close all;
%% Step 1: Load xls file (3D Tumor position)
Load_Data = xlsread(‘Sample 1.xlsx’); % Data include 12 (sec)
% Load_Data = xlsread(‘Sample 2.xlsx’); % Data include 60 (sec)
Time = Load_Data(:,1); % Time (s)
xt=Load_Data(:,2); % xt for targets
yt=Load_Data(:,3); % yt for targets
zt=Load_Data(:,4); % zt for targets
true_T=[xt,yt,zt]; % target locations
[~,numT]=size(true_T); % number of targets
%% Step 2: Define imaging system parameters
SAD = 100; % source-axis distance (cm)
SID = 150; % source-image plane distance (cm)
num_projections = length(Time); % number of different views
% Generate projection angles
alpha = linspace(0, 360, num_projections);
% alpha=30;
theta_rad = deg2rad(alpha); % view angles (radians)
%% Step 3: Projection Model: Compute 2D projections
Xp=zeros(1,num_projections); % allocate array
Yp=zeros(1,num_projections);
for i=1:num_projections
f_theta = (SAD – (true_T(i,1) .* sin(theta_rad(i)) + true_T(i,3) .* cos(theta_rad(i)))) ./ SID;
Xp(1, i) = (true_T(i,1) .* cos(theta_rad(i)) – true_T(i,3) .* sin(theta_rad(i))) ./ f_theta;
Yp(1, i) = true_T(i,2) ./ f_theta;
end
xp = Xp’;
yp = Yp’;
%% Step 4: Define the objective function
% Define the objective function
objFun = @(T) computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections);
%% Step 5: Minimize the objective function using lsqnonlin
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Define bounds
lb = []; % Lower bounds
ub = []; % Upper bounds
% Define optimization options
options = optimoptions(‘lsqnonlin’, …
‘Algorithm’, ‘interior-point’, …
‘Display’, ‘iter’, …
‘MaxIterations’, 300, …
‘MaxFunctionEvaluations’, 20000, …
‘TolFun’, 1e-10, …
‘TolX’, 1e-10, …
‘StepTolerance’, 1e-8, …
‘FiniteDifferenceStepSize’, 1e-3, …
‘UseParallel’, true);
% Generate a better initial guess
T0 = ones(3, num_projections);
% Run optimization for each projection
estimated_T = zeros(3, num_projections);
for i = 1:num_projections
objFun_i = @(T) computeProjectionError(T, xp(i), yp(i), theta_rad(i), SAD, SID, 1);
estimated_T(:, i) = lsqnonlin(objFun_i, T0(:, i), lb, ub, options);
end
%% Step 6: Calculate RMSE value
% Estimated Tumor Position in X, Y, and Z Direction
Estimate_3D_X = estimated_T(1,:);
Estimate_3D_Y = estimated_T(2,:);
Estimate_3D_Z = estimated_T(3,:);
RMSE_x = Calculate_RMSR (xt,Estimate_3D_X);
RMSE_y = Calculate_RMSR (yt,Estimate_3D_Y);
RMSE_z = Calculate_RMSR (zt,Estimate_3D_Z);
fprintf([‘RMSE for X, Y, Z Direction(mm): ‘ …
‘[%.2f, %.2f, %.2f] mmn’], RMSE_x, RMSE_y, RMSE_z);
%% Step 7: Plot Estimated vs Real Data
Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z);
toc;
%% Objective function: Computes error between observed and estimated projections
function error = computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections)
for i=1:num_projections
x_est = T(1,:);
y_est = T(2,:);
z_est = T(3,:);
% Compute estimated projection using the perspective transformation
f_theta = (SAD – (x_est(i) .* sin(theta_rad(i)) + z_est(i) .* cos(theta_rad(i))))./ SID;
xp_est(i) = (x_est(i) .* cos(theta_rad(i)) – z_est(i) .* sin(theta_rad(i))) ./ f_theta;
yp_est(i) = y_est(i) ./ f_theta;
end
%% Compute residual error (Method 1)
% Compute the residual error
error_x = xp – xp_est;
error_y = yp – yp_est;
% Return residuals for least squares minimization
error = [error_x; error_y];
end
function RMSE = Calculate_RMSR (True_value,Estimated_value)
% Calculate RMSE
e1 = (True_value(:)-Estimated_value(:)).^2;
RMSE = sqrt(mean(e1,’omitnan’));
end
function Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z)
figure(‘WindowState’, ‘maximized’)
subplot(3,1,1);
plot(Time, Estimate_3D_X,’r’);
hold on;
plot(Time, xt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘X Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,2);
plot(Time, Estimate_3D_Y,’r’);
hold on;
plot(Time, yt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Y Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,3);
plot(Time, Estimate_3D_Z,’r’);
hold on;
plot(Time, zt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Z Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
endHi there,
I am currently working on a Matlab code for my task (optimization task), and I tried two different methods;
Method A: the fmincon was used to minimize the objective function in which different algorithms, such as interior-point, sqp, sqp-legacy, interior-point, and active-set, were applied.
Method B: Nonlinear least squares optimization was combined with three algorithms, levenberg-marquardt, and trust-region-reflective.
The best results I got now are (from the Nonlinear least squares optimization + ‘interior-point’):
RMSE for X, Y, Z Direction(mm) : [1.18, 0.16, 1.33] mm; however, I want to reduce it as far as it is possible.
@ A quick guide for the code, and how it works.
1. I do have 3D data sets, and I used some mathematical methods to convert these 3D data into 2D data (Step 3).
2. The goal is to use some inverse method to get the same 3D datasets; therefore, after defining the objective function, I applied different optimization methods to address this task.
Any assistance or alternative approaches would be greatly appreciated.
Thank you in advance!
% @ Payam Samadi (2025.3.15) NLSP (Nonlinear least squares optimization)
% In step 3, the 2D projection data was extracted from the 3D data at
% different projections.
% In step4, the objective function is defined.
% In step 5, the Nonlinear least squares optimization is used to minimize
% the objective function.
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Note: It is important to carefully consider the initial guesses for
% target locations, as well as the lower bounds (lb) and upper bounds (ub).
tic;
clc;
clear;
close all;
%% Step 1: Load xls file (3D Tumor position)
Load_Data = xlsread(‘Sample 1.xlsx’); % Data include 12 (sec)
% Load_Data = xlsread(‘Sample 2.xlsx’); % Data include 60 (sec)
Time = Load_Data(:,1); % Time (s)
xt=Load_Data(:,2); % xt for targets
yt=Load_Data(:,3); % yt for targets
zt=Load_Data(:,4); % zt for targets
true_T=[xt,yt,zt]; % target locations
[~,numT]=size(true_T); % number of targets
%% Step 2: Define imaging system parameters
SAD = 100; % source-axis distance (cm)
SID = 150; % source-image plane distance (cm)
num_projections = length(Time); % number of different views
% Generate projection angles
alpha = linspace(0, 360, num_projections);
% alpha=30;
theta_rad = deg2rad(alpha); % view angles (radians)
%% Step 3: Projection Model: Compute 2D projections
Xp=zeros(1,num_projections); % allocate array
Yp=zeros(1,num_projections);
for i=1:num_projections
f_theta = (SAD – (true_T(i,1) .* sin(theta_rad(i)) + true_T(i,3) .* cos(theta_rad(i)))) ./ SID;
Xp(1, i) = (true_T(i,1) .* cos(theta_rad(i)) – true_T(i,3) .* sin(theta_rad(i))) ./ f_theta;
Yp(1, i) = true_T(i,2) ./ f_theta;
end
xp = Xp’;
yp = Yp’;
%% Step 4: Define the objective function
% Define the objective function
objFun = @(T) computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections);
%% Step 5: Minimize the objective function using lsqnonlin
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Define bounds
lb = []; % Lower bounds
ub = []; % Upper bounds
% Define optimization options
options = optimoptions(‘lsqnonlin’, …
‘Algorithm’, ‘interior-point’, …
‘Display’, ‘iter’, …
‘MaxIterations’, 300, …
‘MaxFunctionEvaluations’, 20000, …
‘TolFun’, 1e-10, …
‘TolX’, 1e-10, …
‘StepTolerance’, 1e-8, …
‘FiniteDifferenceStepSize’, 1e-3, …
‘UseParallel’, true);
% Generate a better initial guess
T0 = ones(3, num_projections);
% Run optimization for each projection
estimated_T = zeros(3, num_projections);
for i = 1:num_projections
objFun_i = @(T) computeProjectionError(T, xp(i), yp(i), theta_rad(i), SAD, SID, 1);
estimated_T(:, i) = lsqnonlin(objFun_i, T0(:, i), lb, ub, options);
end
%% Step 6: Calculate RMSE value
% Estimated Tumor Position in X, Y, and Z Direction
Estimate_3D_X = estimated_T(1,:);
Estimate_3D_Y = estimated_T(2,:);
Estimate_3D_Z = estimated_T(3,:);
RMSE_x = Calculate_RMSR (xt,Estimate_3D_X);
RMSE_y = Calculate_RMSR (yt,Estimate_3D_Y);
RMSE_z = Calculate_RMSR (zt,Estimate_3D_Z);
fprintf([‘RMSE for X, Y, Z Direction(mm): ‘ …
‘[%.2f, %.2f, %.2f] mmn’], RMSE_x, RMSE_y, RMSE_z);
%% Step 7: Plot Estimated vs Real Data
Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z);
toc;
%% Objective function: Computes error between observed and estimated projections
function error = computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections)
for i=1:num_projections
x_est = T(1,:);
y_est = T(2,:);
z_est = T(3,:);
% Compute estimated projection using the perspective transformation
f_theta = (SAD – (x_est(i) .* sin(theta_rad(i)) + z_est(i) .* cos(theta_rad(i))))./ SID;
xp_est(i) = (x_est(i) .* cos(theta_rad(i)) – z_est(i) .* sin(theta_rad(i))) ./ f_theta;
yp_est(i) = y_est(i) ./ f_theta;
end
%% Compute residual error (Method 1)
% Compute the residual error
error_x = xp – xp_est;
error_y = yp – yp_est;
% Return residuals for least squares minimization
error = [error_x; error_y];
end
function RMSE = Calculate_RMSR (True_value,Estimated_value)
% Calculate RMSE
e1 = (True_value(:)-Estimated_value(:)).^2;
RMSE = sqrt(mean(e1,’omitnan’));
end
function Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z)
figure(‘WindowState’, ‘maximized’)
subplot(3,1,1);
plot(Time, Estimate_3D_X,’r’);
hold on;
plot(Time, xt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘X Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,2);
plot(Time, Estimate_3D_Y,’r’);
hold on;
plot(Time, yt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Y Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,3);
plot(Time, Estimate_3D_Z,’r’);
hold on;
plot(Time, zt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Z Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
end Hi there,
I am currently working on a Matlab code for my task (optimization task), and I tried two different methods;
Method A: the fmincon was used to minimize the objective function in which different algorithms, such as interior-point, sqp, sqp-legacy, interior-point, and active-set, were applied.
Method B: Nonlinear least squares optimization was combined with three algorithms, levenberg-marquardt, and trust-region-reflective.
The best results I got now are (from the Nonlinear least squares optimization + ‘interior-point’):
RMSE for X, Y, Z Direction(mm) : [1.18, 0.16, 1.33] mm; however, I want to reduce it as far as it is possible.
@ A quick guide for the code, and how it works.
1. I do have 3D data sets, and I used some mathematical methods to convert these 3D data into 2D data (Step 3).
2. The goal is to use some inverse method to get the same 3D datasets; therefore, after defining the objective function, I applied different optimization methods to address this task.
Any assistance or alternative approaches would be greatly appreciated.
Thank you in advance!
% @ Payam Samadi (2025.3.15) NLSP (Nonlinear least squares optimization)
% In step 3, the 2D projection data was extracted from the 3D data at
% different projections.
% In step4, the objective function is defined.
% In step 5, the Nonlinear least squares optimization is used to minimize
% the objective function.
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Note: It is important to carefully consider the initial guesses for
% target locations, as well as the lower bounds (lb) and upper bounds (ub).
tic;
clc;
clear;
close all;
%% Step 1: Load xls file (3D Tumor position)
Load_Data = xlsread(‘Sample 1.xlsx’); % Data include 12 (sec)
% Load_Data = xlsread(‘Sample 2.xlsx’); % Data include 60 (sec)
Time = Load_Data(:,1); % Time (s)
xt=Load_Data(:,2); % xt for targets
yt=Load_Data(:,3); % yt for targets
zt=Load_Data(:,4); % zt for targets
true_T=[xt,yt,zt]; % target locations
[~,numT]=size(true_T); % number of targets
%% Step 2: Define imaging system parameters
SAD = 100; % source-axis distance (cm)
SID = 150; % source-image plane distance (cm)
num_projections = length(Time); % number of different views
% Generate projection angles
alpha = linspace(0, 360, num_projections);
% alpha=30;
theta_rad = deg2rad(alpha); % view angles (radians)
%% Step 3: Projection Model: Compute 2D projections
Xp=zeros(1,num_projections); % allocate array
Yp=zeros(1,num_projections);
for i=1:num_projections
f_theta = (SAD – (true_T(i,1) .* sin(theta_rad(i)) + true_T(i,3) .* cos(theta_rad(i)))) ./ SID;
Xp(1, i) = (true_T(i,1) .* cos(theta_rad(i)) – true_T(i,3) .* sin(theta_rad(i))) ./ f_theta;
Yp(1, i) = true_T(i,2) ./ f_theta;
end
xp = Xp’;
yp = Yp’;
%% Step 4: Define the objective function
% Define the objective function
objFun = @(T) computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections);
%% Step 5: Minimize the objective function using lsqnonlin
% Algorithm:
% 1. ‘levenberg-marquardt’ : [1.21, 0.17, 1.39] mm,
% 2. ‘trust-region-reflective’ : [1.21, 0.17, 1.39] mm,
% 3. ‘interior-point’ : [1.18, 0.16, 1.33] mm
% Define bounds
lb = []; % Lower bounds
ub = []; % Upper bounds
% Define optimization options
options = optimoptions(‘lsqnonlin’, …
‘Algorithm’, ‘interior-point’, …
‘Display’, ‘iter’, …
‘MaxIterations’, 300, …
‘MaxFunctionEvaluations’, 20000, …
‘TolFun’, 1e-10, …
‘TolX’, 1e-10, …
‘StepTolerance’, 1e-8, …
‘FiniteDifferenceStepSize’, 1e-3, …
‘UseParallel’, true);
% Generate a better initial guess
T0 = ones(3, num_projections);
% Run optimization for each projection
estimated_T = zeros(3, num_projections);
for i = 1:num_projections
objFun_i = @(T) computeProjectionError(T, xp(i), yp(i), theta_rad(i), SAD, SID, 1);
estimated_T(:, i) = lsqnonlin(objFun_i, T0(:, i), lb, ub, options);
end
%% Step 6: Calculate RMSE value
% Estimated Tumor Position in X, Y, and Z Direction
Estimate_3D_X = estimated_T(1,:);
Estimate_3D_Y = estimated_T(2,:);
Estimate_3D_Z = estimated_T(3,:);
RMSE_x = Calculate_RMSR (xt,Estimate_3D_X);
RMSE_y = Calculate_RMSR (yt,Estimate_3D_Y);
RMSE_z = Calculate_RMSR (zt,Estimate_3D_Z);
fprintf([‘RMSE for X, Y, Z Direction(mm): ‘ …
‘[%.2f, %.2f, %.2f] mmn’], RMSE_x, RMSE_y, RMSE_z);
%% Step 7: Plot Estimated vs Real Data
Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z);
toc;
%% Objective function: Computes error between observed and estimated projections
function error = computeProjectionError(T, xp, yp, theta_rad, SAD, SID, num_projections)
for i=1:num_projections
x_est = T(1,:);
y_est = T(2,:);
z_est = T(3,:);
% Compute estimated projection using the perspective transformation
f_theta = (SAD – (x_est(i) .* sin(theta_rad(i)) + z_est(i) .* cos(theta_rad(i))))./ SID;
xp_est(i) = (x_est(i) .* cos(theta_rad(i)) – z_est(i) .* sin(theta_rad(i))) ./ f_theta;
yp_est(i) = y_est(i) ./ f_theta;
end
%% Compute residual error (Method 1)
% Compute the residual error
error_x = xp – xp_est;
error_y = yp – yp_est;
% Return residuals for least squares minimization
error = [error_x; error_y];
end
function RMSE = Calculate_RMSR (True_value,Estimated_value)
% Calculate RMSE
e1 = (True_value(:)-Estimated_value(:)).^2;
RMSE = sqrt(mean(e1,’omitnan’));
end
function Plot_results (Time, xt, yt, zt, Estimate_3D_X, Estimate_3D_Y, Estimate_3D_Z)
figure(‘WindowState’, ‘maximized’)
subplot(3,1,1);
plot(Time, Estimate_3D_X,’r’);
hold on;
plot(Time, xt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘X Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,2);
plot(Time, Estimate_3D_Y,’r’);
hold on;
plot(Time, yt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Y Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
subplot(3,1,3);
plot(Time, Estimate_3D_Z,’r’);
hold on;
plot(Time, zt,’b’);
legend (‘Estimate’, ‘Real’);
title (‘Z Dierction’)
xlabel (‘Time (s)’);
ylabel (‘Motion (mm)’)
hold off;
end optimization, fmincon, nonlinear least squares, objective function MATLAB Answers — New Questions
Microsoft’s Attempts to Improve the Teams UI Are Not Always Successful
Auto-Hide Inactive Channels and the New Chat and Channels Interface Just Don’t Work for Some People
It’s hard to create a client user interface that works well on Windows, Mac, and browsers that satisfies the often very different demands which exist in a very large user base (320 million or so, in what’s now a very old official figure). Yet that’s the task that the Teams development group sets itself as it rolls out interface changes. Sometimes, things don’t go to plan.
Solving the Auto-Hide Inactive Channels Mess
Take the plan to auto-hide inactive channels so that old and potentially obsolete channels wouldn’t get in the way of real work. On paper, it sounds like a wonderful idea. Channels do age over time and people do lose interest in what happens in some channels. Manually hiding a bunch of old channels could occupy a rainy Sunday afternoon, but who wants to do that.
The original intention is explained in Microsoft 365 roadmap item 325780, where we discover that “Teams will automatically detect inactive channels you haven’t interacted with in a while, and automatically hide them for you.” Soon after the launch of the feature in July 2024, Microsoft ran into user discontent.
The important word in Microsoft’s description is “automatically.” When software performs an action without human prompting, the results of the processing can be overlooked. In the case of Teams, people reported that important channels disappeared from the Teams and channels list. According to the unexplained algorithm used by Teams, the now-hidden channels appeared inactive and unused, and so liable for hiding. Users could find and unhide channels (Figure 1), but the extra work is a hassle.

The upshot is that Microsoft announced in MC804771 (March 21, 2025) that “Teams will offer users suggestions on channels that are inactive, and the user is prompted to review their inactive channels and hide them only if they choose.” The change to an opt-in model is expected to roll out to general availability “later in 2025.” Let’s hope that Microsoft does a better job this time around.
Moving Away from The New Chat and Channels Experience
Which brings me neatly to the new Teams Chat and Channel experience, trumpeted by Microsoft as being streamlined to help you collaborate more effectively. I’ve used the new interface since its earliest beta release as a new take on how to use channels. After Microsoft released the full version in October 2024, my review led off with “Microsoft’s waffle about the new experience is pure marketing spin.” That note reflected some of my frustration with trying to make the new experience work for me, despite having the opportunity to discuss the matter in depth with some of those responsible for the new interface.
After a further six months of trying, I’ve concluded that I work better with the old experience. I like the separation between chats and Teams. I find it easier to stay on top of current activities and find that I don’t overlook things the way that I do when chats and teams are comingled.
I know others share the same opinion, even if Microsoft’s fabled telemetry tells a different story (but those who construct and control the telemetry get to decide what the story is). I do know of people who love working in the new way, even if it doesn’t work for me. I suspect that the reaction to the new interface is highly individual and greatly influenced by how people work with Teams. As I noted in my review, in some tenants I use chat mostly. In others, it’s channel-based, and in others it’s a combination. I find that chat-centric activities are best in the new experience, but I still decided to revert to the old interface everywhere.
Both the Old and the New
The nice thing is that Teams supports both the old and new experience. In other words, the software respects user choice and doesn’t attempt to force people to do things in the one true way. It’s always better when user choice is respected, especially when changes are introduced in user interfaces. Maybe those responsible for the auto-hide inactive channels feature might have learned that lesson.
Support the work of the Office 365 for IT Pros team by subscribing to the Office 365 for IT Pros eBook. Your support pays for the time we need to track, analyze, and document the changing world of Microsoft 365 and Office 365.
trouver un angle avec l’equation de trajectoire d’un projectile
Bonjour, j’ai un probleme avec ma conception d’un projet de cours j’aimerais calculé l’angle adequat pour mon projectile avec un x0 et y0 en fonction de x mais matlab me donne aucune reponse. voici ce que je recois comme resultat. merciBonjour, j’ai un probleme avec ma conception d’un projet de cours j’aimerais calculé l’angle adequat pour mon projectile avec un x0 et y0 en fonction de x mais matlab me donne aucune reponse. voici ce que je recois comme resultat. merci Bonjour, j’ai un probleme avec ma conception d’un projet de cours j’aimerais calculé l’angle adequat pour mon projectile avec un x0 et y0 en fonction de x mais matlab me donne aucune reponse. voici ce que je recois comme resultat. merci symbolic, trigonometric MATLAB Answers — New Questions
GPU code generation failed with the error ’emlc:compilationError’
When using GPU Coder, I encountered issues with the following environment configuration:
– **GPU Version**: NVIDIA RTX A2000 (Compute Capability 8.6, Ampere Architecture).
– **MATLAB Version**: R2023b.
– **CUDA Toolkit Version**: 11.8.
– **Visual Studio Version**: 2022 (with "Desktop Development with C++" component installed).
When I test
gpuDevice
ans =
CUDADevice – 属性:
Name: ‘NVIDIA RTX A2000’
Index: 1
ComputeCapability: ‘8.6’
SupportsDouble: 1
GraphicsDriverVersion: ‘572.83’
DriverModel: ‘WDDM’
ToolkitVersion: 11.8000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152 (49.15 KB)
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6435504128 (6.44 GB)
AvailableMemory: 5375778816 (5.38 GB)
CachePolicy: ‘balanced’
MultiprocessorCount: 26
ClockRateKHz: 1200000
ComputeMode: ‘Default’
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
If I test coder.checkGpuInstall
coder.checkGpuInstall:
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : FAILED (Error generated while determining cuDNN library version ‘Embedding metadata in the MEX file failed.
‘.)
Host Compiler : PASSED
Basic Code Generation : FAILED (GPU code generation failed with the error ’emlc:compilationError’. View report for further information: View report)
ans =
包含以下字段的 struct:
gpu: 1
cuda: 1
cudnn: 0
tensorrt: 0
hostcompiler: 1
basiccodegen: 0
basiccodeexec: 0
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
test mex -setup
mex -setup
MEX 配置为使用 ‘MinGW64 Compiler (C)’ 以进行 C 语言编译。
要选择不同的 C 编译器,请从以下选项中选择一种命令:
MinGW64 Compiler (C) mex -setup:C:Users石海洋AppDataRoamingMathWorksMATLABR2023bmex_C_win64.xml C
Microsoft Visual C++ 2022 (C) mex -setup:’D:Program FilesMathWorksR2023Bbinwin64mexoptsmsvc2022.xml’ C
要选择不同的语言,请从以下选项中选择一种命令:
mex -setup C++
mex -setup FORTRAN
I looked throught the answers about ’emlc:compilationError’ and "Invalid CUDA device", and see the answer in GPU coder :basic Code Generation failed – MATLAB Answers – MATLAB Central, its issue is caused by a MATLAB version that is too low. However, after reviewing the relevant settings, my MATLAB version should support CUDA 11.8 and VS2022. So, what could be the problem?
PS: I installed cuDNN 8.9 (cudnn-windows-x86_64-8.9.7.29_cuda11-archive) and set the system environment variable `NVIDIA_CUDNN` to: `C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.8`. Why does the cuDNN Environment still show as failed here?When using GPU Coder, I encountered issues with the following environment configuration:
– **GPU Version**: NVIDIA RTX A2000 (Compute Capability 8.6, Ampere Architecture).
– **MATLAB Version**: R2023b.
– **CUDA Toolkit Version**: 11.8.
– **Visual Studio Version**: 2022 (with "Desktop Development with C++" component installed).
When I test
gpuDevice
ans =
CUDADevice – 属性:
Name: ‘NVIDIA RTX A2000’
Index: 1
ComputeCapability: ‘8.6’
SupportsDouble: 1
GraphicsDriverVersion: ‘572.83’
DriverModel: ‘WDDM’
ToolkitVersion: 11.8000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152 (49.15 KB)
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6435504128 (6.44 GB)
AvailableMemory: 5375778816 (5.38 GB)
CachePolicy: ‘balanced’
MultiprocessorCount: 26
ClockRateKHz: 1200000
ComputeMode: ‘Default’
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
If I test coder.checkGpuInstall
coder.checkGpuInstall:
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : FAILED (Error generated while determining cuDNN library version ‘Embedding metadata in the MEX file failed.
‘.)
Host Compiler : PASSED
Basic Code Generation : FAILED (GPU code generation failed with the error ’emlc:compilationError’. View report for further information: View report)
ans =
包含以下字段的 struct:
gpu: 1
cuda: 1
cudnn: 0
tensorrt: 0
hostcompiler: 1
basiccodegen: 0
basiccodeexec: 0
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
test mex -setup
mex -setup
MEX 配置为使用 ‘MinGW64 Compiler (C)’ 以进行 C 语言编译。
要选择不同的 C 编译器,请从以下选项中选择一种命令:
MinGW64 Compiler (C) mex -setup:C:Users石海洋AppDataRoamingMathWorksMATLABR2023bmex_C_win64.xml C
Microsoft Visual C++ 2022 (C) mex -setup:’D:Program FilesMathWorksR2023Bbinwin64mexoptsmsvc2022.xml’ C
要选择不同的语言,请从以下选项中选择一种命令:
mex -setup C++
mex -setup FORTRAN
I looked throught the answers about ’emlc:compilationError’ and "Invalid CUDA device", and see the answer in GPU coder :basic Code Generation failed – MATLAB Answers – MATLAB Central, its issue is caused by a MATLAB version that is too low. However, after reviewing the relevant settings, my MATLAB version should support CUDA 11.8 and VS2022. So, what could be the problem?
PS: I installed cuDNN 8.9 (cudnn-windows-x86_64-8.9.7.29_cuda11-archive) and set the system environment variable `NVIDIA_CUDNN` to: `C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.8`. Why does the cuDNN Environment still show as failed here? When using GPU Coder, I encountered issues with the following environment configuration:
– **GPU Version**: NVIDIA RTX A2000 (Compute Capability 8.6, Ampere Architecture).
– **MATLAB Version**: R2023b.
– **CUDA Toolkit Version**: 11.8.
– **Visual Studio Version**: 2022 (with "Desktop Development with C++" component installed).
When I test
gpuDevice
ans =
CUDADevice – 属性:
Name: ‘NVIDIA RTX A2000’
Index: 1
ComputeCapability: ‘8.6’
SupportsDouble: 1
GraphicsDriverVersion: ‘572.83’
DriverModel: ‘WDDM’
ToolkitVersion: 11.8000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152 (49.15 KB)
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6435504128 (6.44 GB)
AvailableMemory: 5375778816 (5.38 GB)
CachePolicy: ‘balanced’
MultiprocessorCount: 26
ClockRateKHz: 1200000
ComputeMode: ‘Default’
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
If I test coder.checkGpuInstall
coder.checkGpuInstall:
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : FAILED (Error generated while determining cuDNN library version ‘Embedding metadata in the MEX file failed.
‘.)
Host Compiler : PASSED
Basic Code Generation : FAILED (GPU code generation failed with the error ’emlc:compilationError’. View report for further information: View report)
ans =
包含以下字段的 struct:
gpu: 1
cuda: 1
cudnn: 0
tensorrt: 0
hostcompiler: 1
basiccodegen: 0
basiccodeexec: 0
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
test mex -setup
mex -setup
MEX 配置为使用 ‘MinGW64 Compiler (C)’ 以进行 C 语言编译。
要选择不同的 C 编译器,请从以下选项中选择一种命令:
MinGW64 Compiler (C) mex -setup:C:Users石海洋AppDataRoamingMathWorksMATLABR2023bmex_C_win64.xml C
Microsoft Visual C++ 2022 (C) mex -setup:’D:Program FilesMathWorksR2023Bbinwin64mexoptsmsvc2022.xml’ C
要选择不同的语言,请从以下选项中选择一种命令:
mex -setup C++
mex -setup FORTRAN
I looked throught the answers about ’emlc:compilationError’ and "Invalid CUDA device", and see the answer in GPU coder :basic Code Generation failed – MATLAB Answers – MATLAB Central, its issue is caused by a MATLAB version that is too low. However, after reviewing the relevant settings, my MATLAB version should support CUDA 11.8 and VS2022. So, what could be the problem?
PS: I installed cuDNN 8.9 (cudnn-windows-x86_64-8.9.7.29_cuda11-archive) and set the system environment variable `NVIDIA_CUDNN` to: `C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.8`. Why does the cuDNN Environment still show as failed here? gpu coder, basic code generation MATLAB Answers — New Questions