convert a txt file to a structure
Show older comments
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 Comments
KSSV
on 26 Jul 2018
Why don't you attach your text file? specify the error?
Ayman Fathy
on 26 Jul 2018
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!