MATLAB: Synchronization of matlab function blocks
global variablesmatlab codermatlab function blocksimulink
Dear all, I have a simulink model who contains 9 subsystems connected to each other via GoTo-From blocks, each subsystem has a matlab function block (should be the same block, I just copy past from the first subsystem to the other subsystems), my question is regarding the matlab function block, I need to change some variables inside the matlab function in the subsystem number one these variables should be changed instantly in the other blocks as well, I was looking for a way to define the matlab function block to be global or on other words how can I tell the simulink that this matlab function block is the same block in all subsystems so any change in any block either adding a code or updating variables during the simulation time will be instantly applied to the other blocks.
Also I have a question regarding the output of the matlab function block, can this output be treated as an array instead of separated values? The matlab function block code is :
function [UB11,UB12,UB13,UB21,UB22,UB23,UB31,UB32,UB33,I] = fcn %coder.extrinsic('fcn') coder.extrinsic('xlsread'); persistent U; U=zeros(3,3); U=xlsread('C:\Users\Documents\MATLAB\InputImage.xlsx'); UB11=U(1,1); UB12=U(1,2); UB13=U(1,3); UB21=U(2,1); UB22=U(2,2); UB23=U(2,3); UB31=U(3,1); UB32=U(3,2); UB33=U(3,3); I=1; Thank you in advance, Sali
Related Question
- I use persistent variables in a MATLAB Function Block, but do not see them declared as static in generated code? Why is this
- How declare a variable only once in a matlab function block and then use the previous value the nex time the function is used
- Boundary replacement of values in arrays
- How to partition a C source file which calls several void functions that act on global variables into separate C-MEX S-Function blocks in Simulink 8.0 (R2012b)
- Improfile changing colour of plot
- Scope of a variable
- Creating a vector out of variables
Best Answer