Unrecognized function or variable
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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 Commenti
  SALINI  BALASUBARAMANIUM 
 il 28 Mar 2022
				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
      
      
 il 28 Mar 2022
				@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?
Risposte (3)
  the cyclist
      
      
 il 15 Mar 2021
        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 Commenti
  Image Analyst
      
      
 il 15 Mar 2021
				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?
  Image Analyst
      
      
 il 15 Mar 2021
        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 Commenti
  Image Analyst
      
      
 il 15 Mar 2021
				There is no property 'Linewidith', like it says.  Watch your spelling again.  You have 3 i's instead of 2.   It should be 'LineWidth'.
  Ronielson LIma
 il 2 Nov 2021
        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 Commenti
  Walter Roberson
      
      
 il 3 Nov 2021
				You need to install the File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors 
Vedere anche
Categorie
				Scopri di più su Matrix Indexing in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






