transposing and converting excel file
4 次查看(过去 30 天)
显示 更早的评论
Hello; I am a new user. I would like to automate a process that will save me a lot of time. In attached excel file I have some calculations of stresses for different parts. I want to take the data of "Part ID" and "Mean Stresses" and of a string format, which is on right side of excel file, that is compatible with the software I use. The red color and blue color represent the location of the data in string. The rest of the data should not be changed (Each sheet has different data). Finally, all the output should be dumped into a txt file. Is that a possible work to do so? Any kind of help is appreciated. Thank you. Muhsin
0 个评论
回答(1 个)
Walter Roberson
2017-12-10
fid = fopen('final output.txt', 'rt');
data = cell2mat( textscan(fid,'%f%f%f%f%f%f%f%f', 'delimiter',',','comment','*') );
fclose(fid);
data3d = permute(reshape(data,7,[],8),[1 3 2]);
Now data3d is a numeric array, 7 by 8 by the number of "*MAT_USER_DEFINED_MATERIAL_MODELS" blocks. Because your input lines are not all the same size, the shorter rows are padded with NaN.
Nothing in the input file you attached is an obvious part id or mean stress, or red or blue. Also, I do not see what you are asking to do with the data. But at least the above code will read the data into a consistent format suitable for mechanical processing.
3 个评论
Walter Roberson
2017-12-11
That csv appears to have two Part ID and two mean stress entries on each of the main lines.
I do not understand how the input is to map into the output file.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!