I am getting an error Undefined function or variable ***. The first assignment to a local variable determines its class.

12 次查看(过去 30 天)
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 个评论
KSSV
KSSV 2018-4-16
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

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by