Save and load variable
2 次查看(过去 30 天)
显示 更早的评论
how to save and load database in matlab?
0 个评论
回答(3 个)
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.
0 个评论
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 个评论
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 Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!