How to index input parameters?

1 vue (au cours des 30 derniers jours)
JFz
JFz le 19 Août 2015
Commenté : JFz le 24 Août 2015
Hi,
I have a Matlab program that connects to a database and a server. I would like to make the server name and DB name to be dynamic such that the program can read them in from a flat file. Is there a sample code for that? Thanks,
Jennifer

Réponse acceptée

Harsha Medikonda
Harsha Medikonda le 21 Août 2015
I understand that you wish to read the database details from a text file and be able to index into it. Refer to the sample code below
fileID = fopen('scan1.dat');
C = textscan(fileID,'%s %s %f32 %d8 %u %f %f %s %f');
fclose(fileID);
In the above code, C{1}{1} has the first element. In your case if the first element is the database name,you can customize this code to read the entire file, and compare the first element with the database name you are trying to fetch using "strcmp". Once the comparison is successful, you can retrieve the rest of the elements in that row. Refer to the following documentation links on textscan and strcmp.
  1 commentaire
JFz
JFz le 24 Août 2015
Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by