Unrecognized function or variable

8 次查看(过去 30 天)
clear all
clc
range = 1;
t = -range:0.01:range;
w = 1;
P = unit(t+w/2)-unit(t-w/2);
plot(t,P,'Linewidith',5)
grid on
axis([-range-1 range+1 0 1])
title('Rectangel Function');
xlabel('Time(sec)');
ylabel('p(t)');
line([0 0],ylim,'color','r', 'Linewidth',2)
line(xlim,[0 0],'color','r', 'Linewidth',2)
The error I get is as follows. I don't know how to fix this problem. Thank you in advance for your help.
  3 个评论
SALINI  BALASUBARAMANIUM
function [Abar, xbar] = ATPL(K,xcord,initiator,omega,phi,M,N,sigma)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Joint Clock Synchronization and Ranging:
% Asymmetrical Time-stamping and Passive Listening
%
% IEEE Signal Processing Letters, 20 (1): 51 - 54, Jan 2013
% Sundeep Prabhakar Chepuri, CAS, TU Delft.
%
% ATPL script (1 sensor and 10 anchors, or vice versa)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ii= initiator;
speed = 3*10^8;
%observation window
ObsrvWindow = linspace(1,100,K); %1:100; % [s]
for k=1:K
T_i(k,1) = ObsrvWindow(k);
for jj =1:M+N
if(jj==ii)
R_ji(k,jj) = 0;
continue;
end
R_ji(k,jj) = T_i(k,1) + (norm(xcord(:,ii)-xcord(:,jj),2))/speed;
R_ji(k,jj) = omega(jj)*(R_ji(k,jj)+ sqrt(0.5*sigma^2)*randn(1,1)) + phi(jj);
%R_ji(k,jj) = omega(jj)*(R_ji(k,jj)) + phi(jj);
end
T_i(k,1) = omega(ii)*(T_i(k,1) + sqrt(0.5*sigma^2)*randn(1,1)) + phi(ii);
% T_i(k,1) = omega(ii)*(T_i(k,1)) + phi(ii);
end
A1 = []; A2 = []; E1 = []; E2 = [];
for jj = 1:M+N
if (jj==ii)
continue;
elseif (jj <ii)
A1 = blkdiag(A1,-[R_ji(:,jj) ones(K,1)]);
else
A2 = blkdiag(A2,-[R_ji(:,jj) ones(K,1)]);
end
end
tempsizeA1 = size(A1); tempsizeA2 = size(A2);
A1 = [A1; zeros(tempsizeA2(1),tempsizeA1(2))];
A2 = [zeros(tempsizeA1(1),tempsizeA2(2));A2];
A3 = kron(ones(M+N-1,1),[T_i ones(K,1)]);
A = [A1 A3 A2];
temp_comb = nchoosek(1:M+N,2);
%tempS = [1 2]; tempA = [1 3; 2 3];
% colConstrComp = 1;
% colConstr = 2:3;
%tauknwn = [1 2 3 4 6 7 8 10 11 13];
%tauunknwn = [5 9 12 14 15];
tauknwn = find(temp_comb(:,2)~=M+N).';
tauunknw = find(temp_comb(:,2)==M+N).';
E = zeros((M+N-1)*K,length(temp_comb));
flag=0;
tau_i = zeros(length(temp_comb),1);
for jj=1:size(temp_comb,1)
tau_i(jj) = (norm(xcord(:,temp_comb(jj,1))-xcord(:,temp_comb(jj,2)),2))/speed;
end
for vertjj = 1:M+N-1
for horjj=flag+1:length(temp_comb)
if (temp_comb(horjj,1)==ii || temp_comb(horjj,2)==ii) %
E ((vertjj-1)*K+1:vertjj*K,horjj) = ones(K,1);
tau_i(horjj) = (norm(xcord(:,temp_comb(horjj,1))-xcord(:,temp_comb(horjj,2)),2))/speed;
flag=horjj;
break;
end
end
end
Abar = [A(:,1:2*(M+N-1)) E(:,tauunknw)];
xbar = -A(:,2*(M+N-1)+1:end)*[1;0]- E(:,tauknwn)*tau_i(tauknwn);
% Abar = [A(:,1:2*(M+N-1)) E];
% xbar = -A(:,2*(M+N-1)+1:end)*[1;0];
Oaux = ones(M+N-1,1)*ones(M+N-1,1)';
Rmat = 0.5*sigma^2*kron(Oaux, eye(K)) + 0.5*sigma^2*eye((M+N-1)*K);
[V,D] = eig(Rmat);
W = sqrt(inv(D))*V.';
Abar = W*Abar;
xbar = W*xbar;
Image Analyst
Image Analyst 2022-3-28
@SALINI BALASUBARAMANIUM , not sure how your code fixes the "Unrecognized function or variable" error that was mentioned in this year-old question where the user was tring to implement the Heaviside step function. Did you post it here by mistake?

请先登录,再进行评论。

回答(3 个)

the cyclist
the cyclist 2021-3-15
To my knowledge, there it no MATLAB function named unit().
I also used the search bar in the documentation, and did not find anything.
Where did you get this code? Maybe you are missing a second file, that has a user-defined function with that name?
  3 个评论
Image Analyst
Image Analyst 2021-3-15
So I guess it's solved now since you accepted this answer? Was the solution to use uint32() like I suggested in my answer below?
Kutlu Yigitturk
Kutlu Yigitturk 2021-3-15
Thank you for your attenton. I fixed the problem with unusually way. I show the solution top side.

请先登录,再进行评论。


Image Analyst
Image Analyst 2021-3-15
Why did you think it knows what unit is? It does not.
If, by chance, you want to convert to integer use uint32() instead of unit(). Be careful of the location of the "i" and the "n".
  3 个评论
Image Analyst
Image Analyst 2021-3-15
There is no property 'Linewidith', like it says. Watch your spelling again. You have 3 i's instead of 2. It should be 'LineWidth'.
Kutlu Yigitturk
Kutlu Yigitturk 2021-3-15
Thank you for your attenton. I fixed the problem with unusually way. I show the solution top side.

请先登录,再进行评论。


Ronielson LIma
Ronielson LIma 2021-11-2
Good Nitght.
Can you help me please.
Unrecognized function or variable 'distinguishable_colors'.
Error in drawPR (line 8)
methods_colors = distinguishable_colors(length(methods));
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by