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

조회 수: 14 (최근 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