Hi all, I have a question regarding the counter block used in simulink

조회 수: 1 (최근 30일)
I am using a counter block in simulink which will count the number of events when the input was 1 and compare that output to a limit. I want to plot the output of this comparator block for which I tried to use the "To Workspace" block
. But the output is in the format as seen in the attachment and therefore I am finding it difficult to plot. I can understand that there is problem due to the data type, but I am not able to solve that. Can someone help me out with this.
Thanks a lot in advance, Raghavendran

채택된 답변

Orion
Orion 2014년 11월 10일
it seems that your data val has singletons.
to remove them, use squeeze.
clear x
x(1,1,1:3)=1:3
cleandata = squeeze(x)
x(:,:,1) =
1
x(:,:,2) =
2
x(:,:,3) =
3
cleandata =
1
2
3
But why this format, It depends on the configuration of your to workspace block, and also, what is the data you are sending in.
for example
and I can plot the ramp and the sine
Result = squeeze(val);
ramp = Result(1,:);
sine = Result(2,:);
figure;
subplot(211)
plot(ramp)
subplot(212)
plot(sine)

추가 답변 (1개)

Raghavendran Srinivasan
Raghavendran Srinivasan 2014년 11월 10일
hi Orion, Thanks for your help. It works. My data is a structure (along with the corresponding time stamps) of size 2000x2, that I am sending in to the simulink model using the "from workspace" block. This data is processed and the output is what is sent to the counter. Also, since I am using Matlab 2010b, the to workspace block has only 3 options for the output format:
I used the Structure with time option, so that I can plot the output with respect to time.
Thanks, Raghavendran

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by