I am doing a problem on Hamming code in Matlab. I have generated a bit string of length 1190, for transmission. I am asked to display the string as a curve of step function.
After doing some researched i found that the Heaviside function can be used for display the bit string as unit step curve.
When I use the command fplot(heaviside(l_f),[0 ,10000])
, to plot the curve, where l_f
is the bit string of length 1190
, I get this error
Error using fcnchk (line 106)
FUN must be a function, a valid string expression, or an inline function object.
Error in fplot (line 60) fun = fcnchk(fun);
Error in Untitled (line 88) fplot(heaviside(l_f),[0 ,10000])
When i display using Plot, ie plot(heaviside(l_f),[0 ,10000])
, I get the error
Error using plot Vectors must be the same length.
Error in Untitled (line 88) plot(heaviside(l_f),[0 ,10000])
Anyway to plot the bit string as a curve of step function ?
fplot(heaviside(l_f),[0 ,10000])
won't plot since fplot
requires a function
as first parameter. But in here it is a matrix. So use plot
instead. Next, dimension of heaviside(l_f)
will be 1x1190
and dimension of [0 ,10000] is 1x2
. So wont work since dimensions are different so use.
x=heaviside(l_f)
y=0:(10000+1)/length(l_f):10000;
plot(x,y);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.