Azzera filtri
Azzera filtri

Coger los ultimos 4 digitos de cada fila de un string y hacer un string nuevo

4 visualizzazioni (ultimi 30 giorni)
la linea de cada string es de esta forma:
y se tendria que coger los ultimos 4 digitos y hacer un string nuevo.
Muchas gracias

Risposte (1)

Vaibhav il 17 Apr 2024
Modificato: Vaibhav il 17 Apr 2024
Hi flashpode
I understand that you want to extract the last four digits from each line (string) and create a new string using these extracted digits. You can achieve this by using a for loop to extract the last four digits from each line. Here is a code snippet to help you get started:
% Given strings
strings = {
% Initialize an empty string to store the extracted digits
newString = '';
% Extract the last 4 digits from each line
for i = 1:length(strings)
line = strings{i};
last4Digits = line(end-3:end);
newString = [newString, last4Digits];
% Display the new string
disp(['New string with last 4 digits: ', newString]);
New string with last 4 digits: 0000000000000000000000008ioj;P0000010001
Each line is treated as an individual string. If dataset is a single string with lines separated by newlines, you can create an array of strings by splitting on newlines.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!