Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Parsing, Separating, Adding/Mult Integers.

3 visualizaciones (últimos 30 días)
Brian Castro
Brian Castro el 1 de Mzo. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hello. I am trying to write a MATLAB program to replace what would be some rather complex and repetitive awk commands when using Terminal. I am already decent at programming, but have very little experience with MATLAB and it's syntax.
I have multiple lines of text in a .txt document that read something like the following
12MARCH,2011 123456789 That should be output as: 12 3 2011 56877
First I want to separate them out to read: 12 MARCH 2011 123 456 789 Then replace all the months with their corresponding numbers (Jan = 1, Feb = 2, etc). I'm pretty sure I can do this though, once I have column with "MARCH" assigned as a variable I can do something along the lines of
if strcmp(month,"MARCH") month = 3
Last, I want to perform some mathematical operations on the last columns (I was planning on assigning the columns variable names using textread and working from there). This would be something like seperating 123456789 to 123 456 789, and then doing (123)*(456)+789
to get a final output text file of
12 3 2011 56877
So. I already know how to the MATLAB to read a text file, and separate out existing columns as different variables, but how do I separate out strings into multiple columns (12MARCH,2011 -> 12 MARCH 2011), and then, in the case of integers, have it split up a string as separate integers, not strings, so that so that I can later add/multiply them.

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by