FIXED!!

You must add this code to your editor, in this way you call unit() function.

function y = unit(x)

y = zeros(size(x));

y(x>0) = 1

end

107 views (last 30 days)

Show older comments

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.

Image Analyst
on 28 Mar 2022

the cyclist
on 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?

Image Analyst
on 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".

Ronielson LIma
on 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));

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

Start Hunting!