How to create a database/dataset in matlab online?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Deepak
le 16 Jan 2025
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 commentaires
Communautés
Plus de réponses dans Distance Learning Community
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!