MATLAB: Saving Image file as a new file.

imageimage savesave

Hi, so my script consists of the user inputting the name of a file, call it picture, and then I would change the RGB values and show it. The final step is to save the image as newpicture.xxx where xxx is the format they inputted. I have tried save, saveas, imsave and many other ways but I havent been successful. Does anyone have any tips?
name= input('Enter name of file: \n', 's'); %file name
format= input ('Enter format of file: \n', 's');%file format
redchange = input('Change in percent of red: \n');%red change
bluechange = input ('Change in percent of blue: \n');%blue change
greenchange = input ('Change in percent of green: \n');%green change
pic= imread(name, format); %reading image
pic= double(pic); %converting to doubles
pic=pic/255; %scaling everything by dividing by 255.
pic(:,:,1)= redchange*pic(:,:,1); %multiply the values by percentage


pic(:,:,2)= greenchange*pic(:,:,2); %multiply the values by percentage
pic(:,:,3)= bluechange*pic(:,:,3); %multiply the values by percentage
pic(pic>1)=1; %makes sure no values are greater than 1
pic(pic<0)=0; %makes sure no values are less than 0
image(pic) %show image
newname=['new' name]; %change name to new+name
newfile=[newname '.jpg'] %add the format to name
axis off %no axis

Best Answer

It is not useful to write only, that your trials haven't been successful. Btter post the code and explain, what goes wrong, e.g. post the error message.
What about imwrite?