Hello, I want to build a function that extracts METAR data from one specific airport.
The char that I get looks like this:
202005250620 METAR ETSL 250620Z 24008KT 9999 FEW040 BKN060 11/07 Q1031
BLU BLU TEMPO WHT=
202005250620 METAR ETSN 250620Z 29008KT 9999 VCSH FEW020 SCT040 BKN065
12/10 Q1031 BLU BLU TEMPO GRN=
202005250620 METAR ETWM 250620Z 35008KT 9999 VCSH SCT012TCU BKN056 14/10
Q1031 BLU=
StartMETAR= strfind(rawdata,"ETSL")-19
ETSL for example is one Airport. I now want to build a string that starts 20 positions earlier than the station (in oder to include the date) and ends whenever there is an equal sign. However as you can see the strings are always of different length. How can I do this?
Thank you very much already in advance

 채택된 답변

Rik
Rik 2020년 5월 25일

0 개 추천

The code below assumes there is only a single match for 'ETSL'.
StartMETAR=strfind(rawdata,'ETSL')-19;
EndMETAR=strfind(rawdata,'=');
EndMETAR(EndMETAR<=StartMETAR)=[];EndMETAR=EndMETAR(1);%select the first after StartMETAR

댓글 수: 1

Francis Hin
Francis Hin 2020년 5월 25일
Yes it is working poerfectly thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2020년 5월 25일

댓글:

2020년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by