I'm Trying to save a contents into a mat file. But after the contents are saved to a mat file, it shows the file name as :SData_200​_500_20_1.​matSData_1​09_97_116_

The mat file format in my code for saving the record is
save (sprintf('SData_%d_%d_%d_%d.mat',NrGrid,noOfNodes,R,nf,'mat'),'stat_record')
The code is working error free. But The file displayed in folder is saved as
SData_200_500_20_1.matSData_109_97_116_
Then I tried to rename the file by moving to matlab folder as:
SData_200_500_20_1.mat
kindly, help me to solve this problem

Answers (1)

You have already named the file, including the .mat extension, so you don’t need to include it in the sprintf argument list. It is creating problems, because it overflows the numeric fields in your edit descriptor, adding the ‘_109_97_116_’ as it writes the ASCII values of 'mat' to your file name string.
This illustrates the problem:
Q = int8('mat')
Q =
109 97 116
I’m otherwise not certain how to interpret your save call.

5 Comments

I am running a program 10 times. Each time a loop is executed, the data related to file is stored in a new mat file. The file is named using number of nodes, number of grids , number of frequencies used. Hence, I am trying to save a new mat file in each run. This I will be extending to 50 simulations. So for each simulation, I need to create a different mat file. Kindly, help me.
My file is named as SData_NGrids_noOfNodes_nf_TransmissionRange taken in that simulation. This I am doing to identify each file properly for generating graphs and comparing results
Change the save call to:
save (sprintf('SData_%d_%d_%d_%d.mat',NrGrid,noOfNodes,R,nf),'stat_record')
and see if that does what you want.
Thanks its working properly and saving mat file as per desired name. Thanks once again
My pleasure.
If my Answer solved your problem, please Accept it.

This question is closed.

Tags

Asked:

on 2 Aug 2015

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!