Clear Filters
Clear Filters

Undefined function 'drawrectangle' for input arguments of type 'char'?

7 views (last 30 days)
Trying to utilize the 'drawrectangle' function but it's giving me the error you see in the question. I am using R2018a.
This for loop I created (seen below) is to place a series of rectangles of a pre-defined length onto an image. The RawRNA.Data structure are all numbers and correctly defined with the columns of x1, y1, x2, and y2, respectively.
Both variables "w" and "h" (the respective lengths of the rectangle) are being correctly defined too. Below is a screenshot of what RawRNA.Data looks like.
Am I missing something fundamental in the code? Assume everything else before 'drawrectangle' is correctly defined. I'm also happy to provide additional information as you need.
numberofrectangles1=size(RawRNA.Data,1);
A=false(dims.vRNA.(NHPname)(1),dims.vRNA.(NHPname)(2));
figure('Position',[1 1 dims.vRNA.(NHPname)(2) dims.vRNA.(NHPname)(1)])
imshow(adj.vRNA.(NHPname))
axis image;
hold on;
for k = 1 : numberofrectangles1
w=(RawRNA.Data(k,3)-RawRNA.Data(k,1));
h=(RawRNA.Data(k,4)-RawRNA.Data(k,2));
rect=drawrectangle('Position',[RawRNA.Data(k,1),RawRNA.Data(k,2),w,h],'Color','r','LineWidth',1);
rna_roi=createMask(rect);
for j = 1 : dims.vRNA.(NHPname)(1)
for n = 1 : dims.vRNA.(NHPname)(2)
if rna_roi(j,n)==1
A(j,n)=1;
end
end
end
end

Accepted Answer

Image Analyst
Image Analyst on 6 Feb 2021
drawrectangle() was not introduced until R2020a. You will have to use rbbox() or imrect() instead.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!