Variables in workspace are not updated in Simulink when using Matlab function
2 views (last 30 days)
Show older comments
Ramon Ramon on 6 Jun 2020
Answered: Navya Seelam on 9 Jun 2020
So, basically I create a system that produce an output array of repeating square pulse (eg. 111000111000) that I put into the Matlab workspace using a "To Workspace" block as shown in the figure
In the matlab function, I want to create a shifted version of the array to calculate the repeating pattern.So i create a script:
function fest = fcn(phasediff)
phasediffX = [phasediff(end),phasediff(1:end-1)]
phasediffX = [phasediffX(end),phasediffX(1:end-1)]
fest = v
after running the script with Run Model, the only variable that was read in the workspace was the phasediff from the simulink.
How do I integrate these new variables (phasediffX & v) in the function, so i can get a proper output?
Navya Seelam on 9 Jun 2020
Since you have used a single To Workspace block, only single variable phasediff is transferred to MATLAB workspace. In case you are trying to export more variables, use as many To Workspace blocks as required.
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!