??? Error: File: min_max.m Line: 3 Column: 32 Unexpected MATLAB operator.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Uni Lübeck
el 26 de Ag. de 2013
Editada: Varun Keshavan Bhaskara
el 11 de Abr. de 2018
Hi, i want to read a image file using function , and i have just written following 3 lines
what is the reason to show the error
function [min,max]= imread(moon.jpg)
ima=imread(moon.jpg); % reads in image
% display image
imshow(ima);
error is : ??? Error: File: min_max.m Line: 3 Column: 32 Unexpected MATLAB operator.
0 comentarios
Respuesta aceptada
Image Analyst
el 26 de Ag. de 2013
This is a function declaration so you do not list actual argument values in the argument list when you are declaring your function. You use variable names and then pass in the actual values later, when you call it, not when you declare it. Also, don't use min, max, and imread for names of functions or variables since they are reserved built-in names. Do it this way:
function [minValue, maxValue] = my_imread(filename)
minValue = -1; % Initialize
maxValue = -1;
if exist(filename, 'file')
grayImage = imread(filename); % reads in image
% display image
imshow(grayImage);
minValue = min(grayImage(:));
maxValue = max(grayImage(:));
else
errorMessage = sprintf('Error %s does not exist!', filename);
uiwait(warndlg(errorMessage));
end
Then call it
[minValue, maxValue] = my_imread('moon.jpg')
1 comentario
Varun Keshavan Bhaskara
el 11 de Abr. de 2018
Editada: Varun Keshavan Bhaskara
el 11 de Abr. de 2018
hey can you help me out with this projectile motion,, it says
" File: OpenANewFileExample.m Line: 21 Column: 19 Unexpected MATLAB expression."
My code is,
%% projectilemotion
clc
% pm_parameters
% constants
m1=0.15; %kg
m2=0.18; %kg
e=1.5; %mpa
h=1.8; %m
l=0.6;%m
deltal=0.16; %m
r=100; %m
g = 9.81; %m/s^2
theta=45*pi/180; %rad
function[C,Ceq]=pm_nlconst(x)
a=x(1);
v0=x(2);
d=sqrt((v0*v0*m2*4l)/(deltal*deltal*pi*e));
c1 = (sqrt((deltal^2*k*0.5*2)/(m2)))/v0;
c2=((pi*d*d)/4)/a;
C=[c1,c2];
Ceq=[];
end
function[out] = pm(x)
a=x(1);
v0=(x2);
out= ((pi*d*d*e*deltal)/(4*l*0.33));
end
Más respuestas (2)
Azzi Abdelmalek
el 26 de Ag. de 2013
Editada: Azzi Abdelmalek
el 26 de Ag. de 2013
Use
im=imread('moon.jpg')
Do not use min and max as variables (they are Matlab functions). The same remark for your function name:
For example write
function [min1,max1]= image_read(moon.jpg)
ima=imread('moon.jpg'); % reads in image
% display image
imshow(ima);
% your code
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!