How can convert variable-size signal ?

5 次查看(过去 30 天)
Hi, I am getting this error in simulink. can anybody help how can be removed this error ? I only get this error when I attach switch with my ADC block. Also, I have attached the design snap.
The signal at input port 1 of 'ADC_Sign_E_ref_12/Switch2' is a variable-size signal with a nondiscrete sample time. The sample time for any variable-size signal must be discrete.
  4 个评论
Walter Roberson
Walter Roberson 2018-11-12
When a MATLAB Function Block is used, Simulink would tend to assume that the output is variable length. I would not count on the analyzer being able to prove that the output will be scalar: I would recommend configuring the output port.
Also can you post the code so we can see if there is an accidental variable length output path?
Sarfaraz Ahmed
Sarfaraz Ahmed 2018-11-12
编辑:Sarfaraz Ahmed 2018-11-13
Yes sir. I can list code here also I have attached the model. So when you run the model you will see that error and it would be easy to diagnose. I think also it's configuring issue. But I don't know how to configure the output port.
here Vin, Vip are the sampler values.
ADC code:
function y = ADC(Vin, Vip)
coder.extrinsic('stem');
coder.extrinsic('get_param')
sim_t=get_param('ADC_Sign_E_ref_12','SimulationTime')
Nbit = 7;
Vref = 64;
% generating empty plot
ax1=subplot(2,2,([3,4]));
ax2=subplot(2,2,([3,4]));
axis ([ax1 ax2], [0 0.2 -64 64]);
title('Dout Scaler Value');
xlabel('Time(s)');
ylabel('Amplitude');
hold on;
persistent Dout;
if isempty(Dout)
Dout = zeros(1,2);
end
persistent B;
if isempty(B)
B = zeros(1,Nbit);
end
% Conventional Set-and-Down SAR ADC
% 64C, 32C, 16C, 8C, 4C, 2C, C, C
Vxp = Vip;
Vxn = Vin;
for kbit = 1:Nbit
if Vxp - Vxn > 0
B(kbit) = 1;
Vxp = Vxp - Vref*2^(-kbit);
else
B(kbit) = 0;
Vxn = Vxn - Vref*2^(-kbit);
end
end
Dout = B(1)*64 + B(2)*32 + B(3)*16 + B(4)*8 + B(5)*4 + B(6)*2 + B(7)*1 -64 +0.5 ;
stem(sim_t,Dout);
hold on;
y = Dout;
The control signal of switch is coming from below cnt block. The control signal either 0 or 1.
cnt block code:
function y = clk(ip1)
persistent x;
persistent i;
persistent cnt;
persistent out;
if isempty(x) % Initialization
x=1;
end
if isempty(out) % Initialization
out=1;
end
if isempty(cnt) % Initialization
cnt=1;
end
if isempty(i) % Initialization
i=0;
end
while i>=0
cnt = ip1+i;
i=i+1;
break
end
if cnt ==x
out=1;
x=x+4;
else if cnt~=x
out=0;
end
end
y=out;
Please have a look. Thanks

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by