MATLAB Answers

How save the image using strcat ?

28 views (last 30 days)
Oman Wisni
Oman Wisni on 20 Jan 2019
Edited: Oman Wisni on 20 Jan 2019
Hi, I want save my Image in folder there is include the name of image using strcat, I try but error ?
here my function :
function out = uji(fname)
im=imread(fname);
outdir = 'Image Result';
mkdir(outdir);
imwrite (strcat(fname(im(outdir, '1_ori.bmp'))));
out = im;
Could help me please ? thank you

  2 Comments

Stephen Cobeldick
Stephen Cobeldick on 20 Jan 2019
This does not make much sense:
im(outdir, '1_ori.bmp')
If im is an image array, why are you trying to index into it using two chracter vectors?
fname(im(outdir, '1_ori.bmp'))
If fname is a character vector or a string, why are you trying to indexing into it using an image array?
strcat(fname(im(outdir, '1_ori.bmp')))
What are you concatenating together? (There is only one input argument, so you concatenate one thing ... with nothing else).
Oman Wisni
Oman Wisni on 20 Jan 2019
I just want to create the result save on the folder name Image Result with name of image..
So how I fixed it?

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 20 Jan 2019
doc sprintf

  3 Comments

Oman Wisni
Oman Wisni on 20 Jan 2019
I create this code, but the result not save in folder
outdir = 'Image Result';
mkdir(outdir);
imwrite(im,strcat(outdir, fname, '1_ori.bmp'));
How I can save inside folder ? Thanks
Guillaume
Guillaume on 20 Jan 2019
Do not use strcat to build paths. Always use fullfile that is guaranteed to use the correct path separator regardless of which OS you use.
Oman Wisni
Oman Wisni on 20 Jan 2019
Yes sir. Thank you for all the answer. I get what I want.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by