Method 1

Through the eval function

For example

clear

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

R=[1 2 3;4 5 6; 7 8 9]; For I = 1:3% automatically to variable naming and assignment, extraction temperature and resistance from Temp matrix eval ([‘ T ‘, num2str (I), and ‘=’, ‘R (I, :)’, ‘; ‘]); end T1 T2 T3

In the above example, MATLAB automatically defines three variables named T1, T2, and T3; And automatically assign values to these three variables, whose values are each row corresponding to the matrix R, i.e

T1=[1 2 3]

T2=[4 5 6]

T3=[7 8 9]

 

Method 2 (Recommended)

By sprintf

 

numFiles = 3;
for n = 1:numFiles
   randomData = rand(n);
   currentFile = sprintf('myfile%d.mat',n);
   save(currentFile,'randomData')
end
Copy the code

Produced 3 mat files with regular names,

PS: customized development needs, you can contact QQ: 2472853871

Taobao link: item.taobao.com/item.htm?sp…

Provide 1V1 matlab Simulink training, teaching, communication and other consulting services, especially good at automotive control, signal processing, mathematical modeling, motor fields