Could someone kindly point out the syntax/ other error which is preventing my function to scale image from running properly?
function [scaledimage] = scalefunc(img, value)
scaledimage = value*img; %ensures that multiplication occurs element wise;
end
This is the output I am currently getting-
Not enough input arguments.
Error in scale (line 2)
scaledimage = value*img; %ensures that multiplication occurs element wise

 Réponse acceptée

Sai Sri Pathuri
Sai Sri Pathuri le 30 Mai 2020

0 votes

How did you call the function? I assume you didn't pass input arguments
It must be called with input arguments, like
[scaledimage] = scalefunc('Image.jpg', 10)

6 commentaires

MSwar
MSwar le 30 Mai 2020
When I try calling it that way it says
This statement is not inside any function.
(It follows the END that terminates the definition of the function "scalefunc".)
Sai Sri Pathuri
Sai Sri Pathuri le 30 Mai 2020
Can you attach the screenshot of your function call and error message?
MSwar
MSwar le 30 Mai 2020
MSwar
MSwar le 30 Mai 2020
>> scale
Error: File: scale.m Line: 6 Column: 1
This statement is not inside any function.
(It follows the END that terminates the definition of the function "scalefunc".)
Shift these lines to the above of function definition
img = imread('family.png');
imshow(scaledfunc(img, 10))
Currently, your file is a function and expects all statements to be inside function. Change it to a script by making above change
MSwar
MSwar le 30 Mai 2020
Got it! Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by