Why my code is not working in simulink while its ok in matlab?
Show older comments
I have following code
input = [1,0,1,0,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,0];
[m,n] = size(input);
i = 1;
startSig = [1,0,1];
allSwitch = zeros(3,n);
while i <= n-2
if isequal(input(1,i:i+2),startSig)
outputSwitch = bi2de(input(1,i+4:i+5));
j=i+6;
% cond = 0;
k = 1;
output = zeros(1,n);
while j <= n && input(j) ~= 0
output(j) = input(1,j);
k = k+1;
j = j+1;
end
allSwitch(outputSwitch,:)=output;
i = j+1;
else
i = i+1;
end
end
Switch1 = allSwitch(1,:)
Switch2 = allSwitch(2,:)
Switch3 = allSwitch(3,:)
But when I use this code deleting the input values in simulink matlab use defined function block I did not get any out. I use here same input sequence used in matlab as square pulse.
Answers (0)
Categories
Find more on Modeling 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!