フィルターのクリア

transposing and converting excel file

4 ビュー (過去 30 日間)
Muhsin
Muhsin 2017 年 12 月 10 日
コメント済み: Muhsin 2017 年 12 月 11 日
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

回答 (1 件)

Walter Roberson
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
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.
Muhsin
Muhsin 2017 年 12 月 11 日
Dear Walter, I would like to copy the string data on right side of the table for each Part ID that has different Mean Stress values in en each excel sheet. For each Part ID only colored texts is going to be modified. For example, for "layer 16" I am gonna have 32 (from 116 to 3216) data set of string with similar format of input "final output".The only change among these data sets are Part IDs and Mean Stress values which are colored in .csv file as example. Hope I was able to explain it. Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by