How to create a database/dataset in matlab online?
5 ビュー (過去 30 日間)
古いコメントを表示
I want to create a database/dataset in matlab that will run on matlab online. In this database/dataset i will sore some images name and fetch data when online editor run.
0 件のコメント
回答 (1 件)
Deepak
2025 年 1 月 16 日
We can create a dataset in MATLAB by defining image names and descriptions as arrays, storing them in a table, and saving this table to a MAT file. This allows us to persistently store the dataset, which can be easily loaded and accessed later. By loading the MAT file, we can retrieve the dataset and use indexing to fetch specific image names and descriptions, enabling efficient data management both locally and on MATLAB Online.
Below is the sample MATLAB code for the same:
% Create and Save the Dataset
% Define image names and descriptions
imageNames = {'image1.jpg', 'image2.jpg', 'image3.jpg'}; % image names
imageDescriptions = {'Description 1', 'Description 2', 'Description 3'}; % descriptions
% Create a table to store the image names and descriptions
imageDataset = table(imageNames', imageDescriptions', 'VariableNames', {'ImageName', 'Description'});
% Save the table to a MAT file
save('imageDataset.mat', 'imageDataset');
% Display a message
disp('Dataset created and saved to imageDataset.mat');
% Load and Fetch Data from the Dataset
% Load the dataset from the MAT file
load('imageDataset.mat', 'imageDataset');
% Display the entire dataset
disp('Loaded Dataset:');
disp(imageDataset);
% Fetch a particular image name and description by index
index = 1; % Example index;
selectedImageName = imageDataset.ImageName{index};
selectedDescription = imageDataset.Description{index};
% Display the selected image name and description
fprintf('Selected Image: %s\nDescription: %s\n', selectedImageName, selectedDescription);
Please find attached the documentation of functions used for reference:
I hope this will assist in resolving the issue.
0 件のコメント
コミュニティ
その他の回答 遠隔学習コミュニティ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!