convert a txt file to a structure
Afficher commentaires plus anciens
Hello, I read and text scanned a text file into a variable. This variable (1x2 cell) now contains 2 cell arrays each of these cell arrays is a 31x1 cell. One of them contain the names and the other the values. how do I assign each name to its corresponding value? Here is my code but its not working:
clear all;
clc;
PVData = 'w:\Users\james\Documents\MATLAB\readfile.txt';
fid=fopen(PVData);
PVRead=textscan(fid,'%s %f %*[^\n]','delimiter','=','EmptyValue',nan);
fclose(fid);
names = PVRead(1);
values = PVRead(2);
structarray = cell2struct(values, names, 2);
3 commentaires
KSSV
le 26 Juil 2018
Why don't you attach your text file? specify the error?
Ayman Fathy
le 26 Juil 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!