I am getting an error Undefined function or variable ***. The first assignment to a local variable determines its class.
Show older comments
I am getting an error when converting the matlab code to HDL using HDL coder during workflow, "Undefined function or variable 'idx'. The first assignment to a local variable determines its class." and also this error "X must be 'double', 'single', 'logical', or 'char'."
Here is the code
clc
close all;
im=imread('01_h.jpg');
im=imresize(im, [512 512]);
[result, c]=func(im);
imshow(result);
this calls the function
function [color1, centroid] = func(im)
[idx cent]=kmeans(im(:),2,'distance','sqEuclidean','Replicates',3);
color1 = zeros(size(im));
color1(idx==1) = im(idx==1);
end
what should i do to fix it?
1 Comment
KSSV
on 16 Apr 2018
There is a little correction in func
function [color1, centroid] = func(im)
[idx,centroid]=kmeans(im(:),2,'distance','sqEuclidean','Replicates',3);
color1 = zeros(size(im));
color1(idx==1) = im(idx==1);
end
Answers (0)
Categories
Find more on Speed and Area Optimization 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!