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

10 Ansichten (letzte 30 Tage)
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 Kommentar
KSSV
KSSV am 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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by