Variables in workspace are not updated in Simulink when using Matlab function
조회 수: 1 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/310895/image.png)
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)]
for v=1:length(phasediff)
phasediffX = [phasediffX(end),phasediffX(1:end-1)]
if phasediffX==phasediff
break
else
end
end
fest = v
after running the script with Run Model, the only variable that was read in the workspace was the phasediff from the simulink.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/310892/image.png)
How do I integrate these new variables (phasediffX & v) in the function, so i can get a proper output?
댓글 수: 0
답변 (1개)
Navya Seelam
2020년 6월 9일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!