Problem when using imwrite ...

%The directory where the image will be saved
folder = '\Users\public\Documents\MATLAB\faceBank';
name = strcat(Rnombre,Rapellido,Rcargo,'.jpg');
%Are attributes of which the file name will be composed
imwrite(work_area,fullfile(folder,name));
work_area is the variable that contains the image
i have this error
Error using imwrite>parse_inputs (line 510)
A filename must be supplied.
Error in imwrite (line 418)
[data, map, filename, format, paramPairs] = parse_inputs(varargin{:});

回答(1 个)

In your
strcat(Rnombre,Rapellido,Rcargo,'.jpg')
I suspect that one of those variables is a cell array instead of a character vector.
Also if one of them is numeric then you would need to cross check whether the results would be char or numeric. Do not use strcat to try to insert numeric values into a character vector: see sprintf() or num2str for converting numeric to characters.

4 个评论

I get the data in this way, it is assumed that they are already of the "String" type
try with num2str () and sprintf () but it did not work.
if I write the address of the direct file, it works (but it's not what I need)
Rnombre = get(handles.nombreM,'String');
Rapellido = get(handles.apellidoM,'String');
Rcorreo = get(handles.correoM,'String');
Rcargo = get(handles.cargoM,'String');
If one of those is a handle to a uicontrol style edit or text for which Max has been set to more than 1, or if one of them is a handle to a uicontrol style push or pop, then get() of the String will return a cell array of character vectors rather than a character vector.
You should use class() to test each of those variables.
Try
Rnombre = char(handles.nombreM.String);
Rapellido = char(handles.apellidoM.String);
Rcorreo = char(handles.correoM.String);
Rcargo = char(handles.cargoM.String);
Thanks, it worked!

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by