How to change the name of variables inside a file.mat?

조회 수: 3 (최근 30일)
Pietro N
Pietro N 2021년 12월 1일
댓글: Pietro N 2021년 12월 1일
Hi,
I have a file called data.mat in which there are 2 variables called t and C (where C size is 18x6, while t size is 18x1; I want to change their name into texp and Cexp and then save the file.mat with the same name (but with the new name variables inside)
How can I do?

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 12월 1일
How about this?
t=100;C=80; % your data
save('data.mat', 't','C');
clear;
load('data.mat'); %load it first
texp=t; Cexp=C;
save('newdata.mat', 'texp', 'Cexp');
movefile('newdata.mat', 'data.mat'); % replace the old data.mat with the newdata.mat

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Definition에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by