Update variable value to workspace

조회 수: 6 (최근 30일)
Rahul Ramaraj
Rahul Ramaraj 2020년 6월 17일
답변: Sayyed Ahmad 2020년 6월 17일
I am trying to run the following funtion with input u
function output = statespaceEqn(u) %#codegen
coder.gpu.kernelfun()
S = coder.load('matrix.mat');
S.x = S.A*S.x+ S.B*u; %% State Equation
output = S.C*S.x+ S.D*u; %% Output equation
end
I used coder.laod to load my variables 'A' 'B' 'C' 'D' 'x' from my mat file
I defined the variable x with zeros(321,1), but now I want the variable x to be updated with the new value once I run my function.
Could anyone help me to figure this out.
  댓글 수: 1
KSSV
KSSV 2020년 6월 17일
Load the mat file and pcik x from it in the workspace, out side the function. Won't it work?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sayyed Ahmad
Sayyed Ahmad 2020년 6월 17일
I would try to load my variables by useing PostLoad callbacks in model Properties.
Now you have access to this variables by uisng function evalin or assignin. The workspace for your variables in this case would be 'Base'.

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by