Greetings,
in my MATLAB Code (R2017a) i got a variable Matrix ('res') with the typ Char.
For example for one switch it looks like this (8×20):
Carreau-Parameter: a = 7521.1446 Pa*s b = 0.10637 s c = 0.78114 Aktivierungsenergie:E = 40281.5361 J resnorm: 0.030751
The rows and columns of 'res' are variable and as you can see it is a String with variables in it. Therfore i would like to export every text and variable of a row (without the spaces) to a seperate column in exel. Here is an example for the last row:
A1 A2 __________ __ '0.030751' ''
First i build something like this and it worked for just one row:
dname = uigetdir('');fileName = '\Kapillarrheometer.xlsx';s = strcat(dname,fileName);sheet=1;res = ['Carreau-Parameter: ';'a = 7521.1446 Pa*s ']; % and so on...
[r,c] = size(res);for i = 1:r A=strsplit(res(i,:));endalltableres=array2table(A);disp(alltableres);writetable(alltableres,s,'Sheet',Sheet,'Range','C5','WriteVariableNames',0);
After this i tried to create a dynamik Matrix and it worked but isn't realy a good solution because of the varible size of 'res':
dname = uigetdir('');fileName = '\Kapillarrheometer.xlsx';s = strcat(dname,fileName);sheet=1;res = ['Carreau-Parameter: ';'a = 7521.1446 Pa*s ']; % and so on...[r,c] = size(res);%for i = 1:r
A=strsplit(res(1,:)); [Ar,Ac] = size(A); if Ac<5 A=[A nan nan nan]; else A=A; end B=strsplit(res(2,:)); % and so on... allres=[A;B];%end
alltableres=array2table(allres);writetable(alltableres,s,'Sheet',Sheet,'Range','C5','WriteVariableNames',0);disp(alltableres);
Here are the results of 'alltableres':
allres1 allres2 allres3 allres4 allres5 ____________________ _______ ___________ _______ _______ 'Carreau-Parameter:' '' [NaN] [ NaN] [NaN] 'a' '=' '7521.1446' 'Pa*s' ''
I tried to use the cellfun/arrayfun command but it didn't worked quite well. After one week of work i am very tired of this problem…
I am open for every help you can offer!
(This is my first post at this forum. Please tell me if i did something wrong with my inputs!)
Best Answer