As you can see my input is a .txt-File. This .txt-File has several sections for plotting diagrams. One section is my diagram options. I need this variables for formatting my scatter diagram. You can see i store all variables from the section Diagram Options to the variable (table) diagramoptions.
So now to my question: I want to get the value from the variable number_of_plots from the diagramoptions table. How can i do this? Here is my Code and Input-File.
thank you
diagramoptions = [];diagramlimits = [];inputdata = [];diagramoptions2 = [];diagramlimits2 = [];inputdata2 = [];diagramoptions3 = [];diagramlimits3 = [];inputdata3 = [];wholecontent = fileread('Rainflow_Data_Limits_Settings - Copy.txt')sections = regexp(wholecontent, '\*+([^*]+)\*+([^*]+)', 'tokens')for section = sections switch(strtrim(section{1}{1})) % if strcmp(strtrim(section{1}{1}), 'Diagram Options')
case 'Diagram Options' %Diagram Options -> siehe meine Gliederung im .txt file
keyvalues = regexp(section{1}{2}, '([^\n\r=]+)=([^\n\r=]+)', 'tokens')%\n -> new line; \r carriage return
diagramoptions = cell2table(vertcat(keyvalues{:}), 'VariableNames', {'Key', 'Value'}) % end
case 'Diagram Limits' header = strsplit(regexp(section{1}{2}, '[^\n\r]*', 'match', 'once')) content = textscan(section{1}{2}, repmat('%f', 1, numel(header)), 'HeaderLines', 2) diagramlimits = table(content{:}, 'VariableNames', header) case 'Input Data' inputdata = cell2mat(textscan(section{1}{2}, '%f%f%f', 'HeaderLines', 1))%dh: ich habe 1 Headerline zur besseren übersicht
case 'Diagram Options2' %Diagram Options -> siehe meine Gliederung im .txt file keyvalues2 = regexp(section{1}{2}, '([^\n\r=]+)=([^\n\r=]+)', 'tokens')%\n -> new line; \r carriage return diagramoptions2 = cell2table(vertcat(keyvalues{:}), 'VariableNames', {'Key', 'Value'}) case 'Diagram Limits2' header2 = strsplit(regexp(section{1}{2}, '[^\n\r]*', 'match', 'once')) content2 = textscan(section{1}{2}, repmat('%f', 1, numel(header2)), 'HeaderLines', 2) diagramlimits2 = table(content2{:}, 'VariableNames', header2) case 'Input Data2' inputdata2 = cell2mat(textscan(section{1}{2}, '%f%f%f', 'HeaderLines', 1))%dh: ich habe 1 Headerline zur besseren übersicht case 'Diagram Options3' %Diagram Options -> siehe meine Gliederung im .txt file keyvalues3 = regexp(section{1}{2}, '([^\n\r=]+)=([^\n\r=]+)', 'tokens')%\n -> new line; \r carriage return diagramoptions3 = cell2table(vertcat(keyvalues{:}), 'VariableNames', {'Key', 'Value'}) case 'Diagram Limits3' header3 = strsplit(regexp(section{1}{2}, '[^\n\r]*', 'match', 'once')) content3 = textscan(section{1}{2}, repmat('%f', 1, numel(header3)), 'HeaderLines', 2) diagramlimits3 = table(content3{:}, 'VariableNames', header3) case 'Input Data3' inputdata3 = cell2mat(textscan(section{1}{2}, '%f%f%f', 'HeaderLines', 1))%dh: ich habe 1 Headerline zur besseren übersicht otherwise warning('Unknown section: %s', section{1}{1}) end end%öffnet die output fenster
openvar diagramoptionsopenvar diagramlimits openvar inputdata openvar diagramoptions2openvar diagramlimits2openvar inputdata2 openvar diagramoptions3openvar diagramlimits3 openvar inputdata3
Best Answer