0

I have script in MATLAB that uses the subplot function. Now I know that it takes 3 arguments minimum to work as I have seen in the MATLAB docs. However, it give an error saying too many input arguments. This is the code

%% ================= Part 5: Image Compression ======================


% Find closest cluster members
idx = findClosestCentroids(X, centroids);

% Essentially, now we have represented the image X as in terms of the
% indices in idx. 

% We can now recover the image from the indices (idx) by mapping each pixel
% (specified by its index in idx) to the centroid value
X_recovered = centroids(idx,:);

% Reshape the recovered image into proper dimensions
X_recovered = reshape(X_recovered, img_size(1), img_size(2), 3);

% Display the original image 
subplot(1, 2, 1);
imagesc(A); 
title('Original');

% Display compressed image side by side
subplot(1, 2, 2);
imagesc(X_recovered)
title(sprintf('Compressed, with %d colors.', K));

At the '%Display the original image section', it is giving an error saying

Error using subplot
Too many input arguments.
Error in ex7 (line 162)
subplot(1,2,1);

I cannot understand why MATLAB will be giving such an error. Please explain.

2
  • 1
    Is there a file in the local directory called subplot? Commented May 28, 2017 at 6:26
  • Tell the result of which subplot Commented May 28, 2017 at 6:36

1 Answer 1

1

it look like you have another function with the same name. search for sub function in the same file or search for global file:

which subplot -all
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.