Wie kann ich Strings die speziell markiert sind "ersetz
Philipp M
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am : 10.04.2017, 20:09
Titel : Wie kann ich Strings die speziell markiert sind "ersetz
Hallo,
Ich habe eine Frage. Ich lese von einem .txt-File Daten ein.
Ich möchte Matlab mit irgendeinem Keybuchstaben oder Sonderzeichen mitteilen dass gewisse Wörter anders behandelt werden solen bzw. ersetzt werden müssen. Zb mit "Stern markiert": *Sigma* soll im CODE als \sigma ersetzt werden....
Mein Code:
Code:
%Allgemeine Initalsierungen
r_inputdataSigmaX=[ ;] ;
r_inputdataSigmaY=[ ;] ;
r_inputdataTau=[ ;] ;
w_inputdataTau=[ ;] ;
w_inputdataSigmaY=[ ;] ;
w_inputdataSigmaX=[ ;] ;
cuttofflinesSigmaX=[ ;] ;
cuttofflinesSigmaY=[ ;] ;
cuttofflinesTau=[ ;] ;
r_inputdata_logic=zeros ( 1 ,3 ) ;
w_inputdata_logic=zeros ( 1 ,3 ) ;%[ 0 ;0 ;0 ] ; %zeros ( m,n)
inputdata_cuttofflines_logic=zeros ( 1 ,3 ) ;%[ 0 ;0 ;0 ] ;
default_value_z=1e8; %hier setze defaultmässig die z Komponente/Wert der Cutofflinien
row1=0 ;
row2=0 ;
row3=0 ;
index_counter=1 ;
t=0 ;
%Einlese Prozedere
wholecontent = fileread ( 'MatlabExport_2.txt ')
sections = regexp ( wholecontent, '\*+( [ ^*] +) \*+( [ ^*] +) ', 'tokens ')
for section = sections
switch ( strtrim ( section{ 1 } { 1 } ) )
case 'Plot Page Options and Settings '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
plotpageSettings = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Die Diagram Options gelten jeweils für rainflow und woehler
case 'Diagram Options SigmaX '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
diagramoptionsSigmaX = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
case 'Diagram Options SigmaY '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
diagramoptionsSigmaY = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
case 'Diagram Options Tau '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
diagramoptionsTau = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'Woehler Lines SigmaX '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
w_diagramoptionsSigmaX = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
w_inputdata_logic( 1 ,1 ) = 1 ;
case 'Woehler Lines SigmaY '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
w_diagramoptionsSigmaY = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
w_inputdata_logic( 1 ,2 ) = 1 ;
case 'Woehler Lines Tau '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
w_diagramoptionsTau = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
w_inputdata_logic( 1 ,3 ) = 1 ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'Rainflow Options SigmaX '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
r_diagramoptionsSigmaX = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
case 'Rainflow Options SigmaY '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
r_diagramoptionsSigmaY = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
case 'Rainflow Options Tau '
keyvalues = regexp ( section{ 1 } { 2 } , '( [ ^\n\r=] +) =( [ ^\n\r=] +) ', 'tokens ')
r_diagramoptionsTau = cell2table( vertcat ( keyvalues{ :} ) , 'VariableNames ', { 'Key ', 'Value '} )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'Rainflow Cutofflines SigmaX '
cuttofflinesSigmaX = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
inputdata_cuttofflines_logic( 1 ,1 ) = 1 ;
case 'Rainflow Cutofflines SigmaY '
cuttofflinesSigmaY = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
inputdata_cuttofflines_logic( 1 ,2 ) = 1 ;
case 'Rainflow Cutofflines Tau '
cuttofflinesTau = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
inputdata_cuttofflines_logic( 1 ,3 ) = 1 ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'StressSpectrum Data SigmaX '
w_inputdataSigmaX = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
case 'StressSpectrum Data SigmaY '
w_inputdataSigmaY = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
case 'StressSpectrum Data Tau '
w_inputdataTau = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f ', 'HeaderLines ', 1 ) )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'Rainflow Data SigmaX '
r_inputdataSigmaX = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f%f ', 'HeaderLines ', 1 ) )
r_inputdata_logic( 1 ,1 ) = 1 ;
case 'Rainflow Data SigmaY '
r_inputdataSigmaY = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f%f ', 'HeaderLines ', 1 ) )
r_inputdata_logic( 1 ,2 ) = 1 ;
case 'Rainflow Data Tau '
r_inputdataTau = cell2mat ( textscan ( section{ 1 } { 2 } , '%f%f%f ', 'HeaderLines ', 1 ) )
r_inputdata_logic( 1 ,3 ) = 1 ;
otherwise
warning ( 'Unknown section ERROR : %s ', section{ 1 } { 1 } )
end
end
diagramheader=diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_diagramheaderSigmaX ') )
labelabscissa=diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_labelabscissaSigmaX ') )
labelordinate=diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_labelordinateSigmaX ') )
ordinateLogarithmic=diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_ordinateLogarithmic ') )
abscissaMin=str2double ( diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_abscissaMinSigmaX ') ) )
abscissaMax=str2double ( diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_abscissaMaxSigmaX ') ) )
ordinateMin=str2double ( diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_ordinateMinSigmaX ') ) )
ordinateMax=str2double ( diagramoptionsSigmaX.Value ( strcmp ( diagramoptionsSigmaX.Key , 'w_ordinateMaxSigmaX ') ) )
Mein Input .txt:
Zitat:
********************Plot Page Options and Settings******
pageheader=dummy0
*******************Diagram Options SigmaX************
r_diagramheaderSigmaX=Rainflow-Matrix *sigma_x*
r_labelordinateSigmaX=Amplitude *sigma_a*
r_labelabscissaSigmaX=Mittelwert *sigma_m*
r_abscissaMinSigmaX=8.6625
r_abscissaMaxSigmaX=28.4625
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
Impressum
| Nutzungsbedingungen
| Datenschutz
| FAQ
| RSS
Hosted by:
Copyright © 2007 - 2025
goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.