Author: PuTI
Generate ST code from a look-up table with CONSTANT attribute
Hi,
I am using the ‘Direct Lookup Table (n-D)’ block in Simulink to load a matrix and extract the values given a row and a column number as inputs.
The Simulink setup is shown in the attached figure "lookup-table.png".
With this setup a PLC function block in structured text is generated from MATLAB/Simulink and everything is working as expected. However, the look-up table is defined within the function block as "VAR". I would like, if possible, to define it as "VAR_CONSTANT" instead. I have tried setting the in the lookup table attribute "StorageClass" type to "Const" but that has not worked.
Any idea/suggestion on how to store this table as "VAR_CONSTANT"?
Thanks in advance.Hi,
I am using the ‘Direct Lookup Table (n-D)’ block in Simulink to load a matrix and extract the values given a row and a column number as inputs.
The Simulink setup is shown in the attached figure "lookup-table.png".
With this setup a PLC function block in structured text is generated from MATLAB/Simulink and everything is working as expected. However, the look-up table is defined within the function block as "VAR". I would like, if possible, to define it as "VAR_CONSTANT" instead. I have tried setting the in the lookup table attribute "StorageClass" type to "Const" but that has not worked.
Any idea/suggestion on how to store this table as "VAR_CONSTANT"?
Thanks in advance. Hi,
I am using the ‘Direct Lookup Table (n-D)’ block in Simulink to load a matrix and extract the values given a row and a column number as inputs.
The Simulink setup is shown in the attached figure "lookup-table.png".
With this setup a PLC function block in structured text is generated from MATLAB/Simulink and everything is working as expected. However, the look-up table is defined within the function block as "VAR". I would like, if possible, to define it as "VAR_CONSTANT" instead. I have tried setting the in the lookup table attribute "StorageClass" type to "Const" but that has not worked.
Any idea/suggestion on how to store this table as "VAR_CONSTANT"?
Thanks in advance. plc coder, structured text MATLAB Answers — New Questions
MATLAB Answers is provisionally back?
It is currently working for me?It is currently working for me? It is currently working for me? meta MATLAB Answers — New Questions
Saveobj and Loadobj for arrays of objects
I am trying to customize the save() and load() process for a classdef. Cuurrently, I am using old-style saveobj() and loadobj() methods, as I am still trying to get familiar with the newer approach.
Unlike most class methods, calling saveobj and load obj on an array of objects,
saveobj(objArray)
loadobj(objArray)
does not result in the entirety of objArray being passed to the user-provided code. Instead, there is some background Matlab process that invokes them one element at a time, equivalent to,
for i=1:numel(objArray)
saveobj(objArray(i))
loadobj(objArray(i))
end
However, my saveobj() and loadobj needs to know things about the entire array being saved, and calling them one element at a time hides this information. Is there any way to overcome this problem? As I said, I am still getting acquainted with the newer custom serialization and deserialization tools. Is there any chance that could hold a solution?I am trying to customize the save() and load() process for a classdef. Cuurrently, I am using old-style saveobj() and loadobj() methods, as I am still trying to get familiar with the newer approach.
Unlike most class methods, calling saveobj and load obj on an array of objects,
saveobj(objArray)
loadobj(objArray)
does not result in the entirety of objArray being passed to the user-provided code. Instead, there is some background Matlab process that invokes them one element at a time, equivalent to,
for i=1:numel(objArray)
saveobj(objArray(i))
loadobj(objArray(i))
end
However, my saveobj() and loadobj needs to know things about the entire array being saved, and calling them one element at a time hides this information. Is there any way to overcome this problem? As I said, I am still getting acquainted with the newer custom serialization and deserialization tools. Is there any chance that could hold a solution? I am trying to customize the save() and load() process for a classdef. Cuurrently, I am using old-style saveobj() and loadobj() methods, as I am still trying to get familiar with the newer approach.
Unlike most class methods, calling saveobj and load obj on an array of objects,
saveobj(objArray)
loadobj(objArray)
does not result in the entirety of objArray being passed to the user-provided code. Instead, there is some background Matlab process that invokes them one element at a time, equivalent to,
for i=1:numel(objArray)
saveobj(objArray(i))
loadobj(objArray(i))
end
However, my saveobj() and loadobj needs to know things about the entire array being saved, and calling them one element at a time hides this information. Is there any way to overcome this problem? As I said, I am still getting acquainted with the newer custom serialization and deserialization tools. Is there any chance that could hold a solution? saveobj, loadobj, serialization, deserialization, save, load, oop, classdef MATLAB Answers — New Questions
Microsoft Build 2025: The age of AI agents and building the open agentic web
TL;DR? Hear the news as an AI-generated audio overview made using Microsoft 365 Copilot. You can read the transcript here.
We’ve entered the era of AI agents. Thanks to groundbreaking advancements in reasoning and memory, AI models are now more capable and efficient, and we’re seeing how AI systems can help us all solve problems in new ways.
For example, 15 million developers are already using GitHub Copilot, and features like agent mode and code review are streamlining the way they code, check, deploy and troubleshoot.
Hundreds of thousands of customers are using Microsoft 365 Copilot to help research, brainstorm and develop solutions, and more than 230,000 organizations — including 90% of the Fortune 500 — have already used Copilot Studio to build AI agents and automations.
Companies like Fujitsu and NTT DATA are using Azure AI Foundry to build and manage AI apps and agents that help prioritize sales leads, speed proposal creation and surface client insights. Stanford Health Care is using Microsoft’s healthcare agent orchestrator to build and test AI agents that can help alleviate the administrative burden and speed up the workflow for tumor board preparation.
Developers are at the center of it all. For 50 years Microsoft has been empowering developers with tools and platforms to turn their ideas into reality, accelerating innovation at every stage. From AI-driven automation to seamless cloud integration and more, it’s exciting to see how developers are fueling the next generation of digital transformation.
So, what’s next?
We envision a world in which agents operate across individual, organizational, team and end-to-end business contexts. This emerging vision of the internet is an open agentic web, where AI agents make decisions and perform tasks on behalf of users or organizations.
At Microsoft Build we’re showing the steps we’re taking to make this vision a reality through our platforms, products and infrastructure. We’re putting new models and coding agents in the hands of developers, introducing enterprise-grade agents, making our platforms like Azure AI Foundry, GitHub and Windows the best places to build, embracing open protocols and accelerating scientific discovery with AI, all so that developers and organizations can go invent the next big thing.
Here’s a glimpse at just a few of the announcements today:
Reimagining the software development lifecycle with AI
AI is fundamentally shifting how code is written, deployed and maintained. Developers are using AI to stay in the flow of their environment longer and to shift their focus to more strategic tasks. And as the software development lifecycle is being transformed, we’re providing new features across platforms including GitHub, Azure AI Foundry and Windows that enable developers to work faster, think bigger and build at scale.
- GitHub Copilot coding agent and new updates to GitHub Models: GitHub Copilot is evolving from an in-editor assistant to an agentic AI partner with a first-of-its-kind asynchronous coding agent integrated into the GitHub platform. We’re adding prompt management, lightweight evaluations and enterprise controls to GitHub Models so teams can experiment with best-in-class models, without leaving GitHub. Microsoft is also open-sourcing GitHub Copilot Chat in VS Code. The AI-powered capabilities from GitHub Copilot extensions will now be part of the same open-source repository that drives the world’s most popular development tool. As the home of over 150 million developers, this reinforces our commitment to open, collaborative, AI-powered software development. Learn more about GitHub Copilot updates.
- Introducing Windows AI Foundry: For developers, Windows remains one of the most open and widely used platforms available, with scale, flexibility and growing opportunity. Windows AI Foundry offers a unified and reliable platform supporting the AI developer lifecycle across training and inference. With simple model APIs for vision and language tasks, developers can manage and run open source LLMs via Foundry Local or bring a proprietary model to convert, fine-tune and deploy across client and cloud. Windows AI Foundry is available to get started today. To learn more visit our Windows Developer Blog.
- Azure AI Foundry Models and new tools for model evaluation: Azure AI Foundry is a unified platform for developers to design, customize and manage AI applications and agents. With Azure AI Foundry Models, we’re bringing Grok 3 and Grok 3 mini models from xAI to our ecosystem, hosted and billed directly by Microsoft. Developers can now choose from more than 1,900 partner-hosted and Microsoft-hosted AI models, while managing secure data integration, model customization and enterprise-grade governance. We’re also introducing new tools like the Model Leaderboard, which ranks the top-performing AI models across different categories and tasks, and the Model Router, designed to select an optimal model for a specific query or task in real-time. Read more about Azure AI Foundry Models.
Making AI agents more capable and secure
AI agents are not only changing how developers build, but how individuals, teams and companies get work done. At Build, we’re unveiling new pre-built agents, custom agent building blocks, multi-agent capabilities and new models to help developers and organizations build and deploy agents securely to help increase productivity in meaningful ways.
- With the general availability of Azure AI Foundry Agent Service, Microsoft is bringing new capabilities to empower professional developers to orchestrate multiple specialized agents to handle complex tasks, including bringing Semantic Kernel and AutoGen into a single, developer-focused SDK and Agent-to-Agent (A2A) and Model Context Protocol (MCP) support. To help developers build trust and confidence in their AI agents, we’re announcing new features in Azure AI Foundry Observability for built-in observability into metrics for performance, quality, cost and safety, all incorporated alongside detailed tracing in a streamlined dashboard. Learn more about how to deploy enterprise-grade AI agents in Azure AI Foundry Service.
- Discover, protect and govern in Azure AI Foundry: With Microsoft Entra Agent ID, now in preview, agents that developers create in Microsoft Copilot Studio or Azure AI Foundry are automatically assigned unique identities in an Entra directory, helping enterprises securely manage agents right from the start and avoid “agent sprawl” that could lead to blind spots. Apps and agents built with Foundry further benefit from Purview data security and compliance controls. Foundry also offers enhanced governance tools to set risk parameters, run automated evaluations and receive detailed reports. Learn more about Microsoft Entra Agent ID and Azure AI Foundry integrations with Microsoft Purview Compliance Manager.
- Introducing Microsoft 365 Copilot Tuning and multi-agent orchestration: With Copilot Tuning, customers can use their own company data, workflows and processes to train models and create agents in a simple, low-code way. These agents perform highly accurate, domain-specific tasks securely from within the Microsoft 365 service boundary. For example, a law firm can create an agent that generates documents aligned with its organization’s expertise and style. Additionally, new multi-agent orchestration in Copilot Studio connects multiple agents, allowing them to combine skills and tackle broader, more complex tasks. Check out the Microsoft 365 blog to learn how to access these new tools as well as the Microsoft 365 Copilot Wave 2 spring release, which has moved to general availability and begins rolling out today.
Supporting the open agentic web
To realize the future of AI agents, we’re advancing open standards and shared infrastructure to provide unique capabilities for customers.
- Supporting Model Context Protocol (MCP): Microsoft is delivering broad first-party support for Model Context Protocol (MCP) across its agent platform and frameworks, spanning GitHub, Copilot Studio, Dynamics 365, Azure AI Foundry, Semantic Kernel and Windows 11. In addition, Microsoft and GitHub have joined the MCP Steering Committee to help advance secure, at-scale adoption of the open protocol and announced two new contributions to the MCP ecosystem, an updated authorization specification, which enables people to use their existing trusted sign-in methods to give agents and LLM-powered apps access to data and services such as personal storage drives or subscription services, and the design of an MCP server registry service, which allows anyone to implement public or private, up-to-date, centralized repositories for MCP server entries. Check out the GitHub repository. As we expand our MCP capabilities, our top priority is to ensure we’re building upon a secure foundation. To learn more about this approach see: Securing the Model Context Protocol: Building a Safe Agentic Future on Windows.
- A new open project called NLWeb: Microsoft is introducing NLWeb, which we believe can play a similar role to HTML for the agentic web. NLWeb makes it easy for websites to provide a conversational interface for their users with the model of their choice and their own data, allowing users to interact directly with web content in a rich, semantic manner. Every NLWeb endpoint is also an MCP server, so websites can make their content easily discoverable and accessible to AI agents if they choose. Learn more here.
Accelerating scientific discovery with AI
Science may be one of the most important applications of AI, helping to tackle humanity’s most pressing challenges, from drug discovery to sustainability. At Build we’re introducing Microsoft Discovery, an extensible platform built to empower researchers to transform the entire discovery process with agentic AI, helping research and development departments across various industries accelerate the time to market for new products and accelerate and expand the end-to-end discovery process for all scientists. Learn more here.
This is only a small selection of the many exciting features and updates we will be announcing at Build. We’re looking forward to connecting with those who have registered to join us virtually and in-person, for keynote sessions, live code deep dives, hack sessions and more — much of which will be available on demand.
Plus, you can get more on all these announcements by exploring the Book of News, the official compendium of all today’s news.
The post Microsoft Build 2025: The age of AI agents and building the open agentic web appeared first on The Official Microsoft Blog.
TL;DR? Hear the news as an AI-generated audio overview made using Microsoft 365 Copilot. You can read the transcript here. We’ve entered the era of AI agents. Thanks to groundbreaking advancements in reasoning and memory, AI models are now more capable and efficient, and we’re seeing how AI systems can help us all solve…
The post Microsoft Build 2025: The age of AI agents and building the open agentic web appeared first on The Official Microsoft Blog.Read More
test one two three four
this is a test to see whether posting questions is back workingthis is a test to see whether posting questions is back working this is a test to see whether posting questions is back working meta, test MATLAB Answers — New Questions
Is it possible to make this tiny loop faster?
It seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
endIt seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
end It seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
end vectorization, for loop, speed MATLAB Answers — New Questions
Solar Wind Battery Hybrid Integration
I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT.I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT. I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT. solar, wind, mppt, hybrid model, dc bus MATLAB Answers — New Questions
Why does it say “invalid email or password” when i reinstall r2023b Product
I have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalilaI have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalila I have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalila invalid password or email MATLAB Answers — New Questions
TIFF from ImageJ not loading correctly in R2024b (worked in R2022b)
Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks!Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks! Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks! tiff, 3d reconstruction, matlab2024b, image proces MATLAB Answers — New Questions
Regarding using trainnet, testnet in binary image classification(size difference between network output and test data output)
Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading.Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading. Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading. binaryclassification, cnn, trainnet, deeplearning, testnet MATLAB Answers — New Questions
Optimal decimation to Log Simulation Data
Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You!Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You! Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You! power_electronics_control MATLAB Answers — New Questions
I need to use a scope to display the current i and the power P as functions of the voltage V, with the curves obtained for various irradiance levels and temperatures
1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples!1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples! 1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples! photovoltaic panel, current, voltage, power, scope MATLAB Answers — New Questions
Break in and break away points on Root Locus
Hi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
NielHi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
Niel Hi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
Niel matlab, root locus MATLAB Answers — New Questions
External Mode Connection Issue with C2000 LaunchPad and Speedgoat System
Dear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun ShahiDear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun Shahi Dear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun Shahi c2000 blockset issue MATLAB Answers — New Questions
Transfer history to MATLAB 2025a
Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a?Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a? Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a? matlab MATLAB Answers — New Questions
how to validate mscohere?
I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use?I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use? I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use? mscohere MATLAB Answers — New Questions
Constraints to a Second Order Curve Fit
Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6)Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6) Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6) curve fitting, matlab, polyfit MATLAB Answers — New Questions
S curve ramp function
I need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
endI need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
end I need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
end s curve MATLAB Answers — New Questions
How to create excel sheet for developed model using MATLAB
I have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solutionI have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solution I have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solution importing excel data, testing, mil, matlab MATLAB Answers — New Questions
How to express constants of integral
Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u)Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u) Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u) integral, constants of integral MATLAB Answers — New Questions