Save and load variable

조회 수: 2 (최근 30일)
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN 2023년 6월 5일
편집: the cyclist 2023년 6월 5일
how to save and load database in matlab?

답변 (3개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2023년 6월 5일
You may use load function, detail here

the cyclist
the cyclist 2023년 6월 5일
Your question title just says "variable", but your question itself asks about databases. Assuming you actually mean database access, then here is extensive documentation about accessing relational databases from MATLAB.

Diwakar Diwakar
Diwakar Diwakar 2023년 6월 5일
Try this code:
% Create sample data
data = [1 2 3; 4 5 6; 7 8 9];
% Saving data to a CSV file
csvwrite('database.csv', data);
% Clear the data variable
clear data
% Loading data from the CSV file
data = csvread('database.csv');
% Display the loaded data
disp(data);
1 2 3 4 5 6 7 8 9
  댓글 수: 1
the cyclist
the cyclist 2023년 6월 5일
편집: the cyclist 2023년 6월 5일
At this point it is still very unclear what @RACHEL LYN JAHIRIN is actually trying to do, so this answer may be useful. But I'd like to point out a couple things about it:
  • Naming a CSV file "database" doesn't mean that it is a database (except in the most extremely pedantic way).
  • csvread and csvwrite are functions that are specifically recommended against. If this answer is what the OP wanted, I would suggest using readmatrix and writematrix instead.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by