Isolate Elements in a Vector

1 visualización (últimos 30 días)
T
T el 24 de En. de 2013
Suppose I have two sets of data:
ab =
0.3570
0.3560
0.3750
0.5150
0.3570
0.3560
0.3750
0.5150
and
ab =
0.4100
0.2500
0.3340
0.5500
0.6250
0.7760
0.3330
0.4100
0.2500
0.3340
0.5500
0.6250
0.7760
0.3330
0.4100
0.2500
0.3340
0.5500
0.6250
0.7760
0.3330
0.4100
0.2500
0.3340
0.5500
0.6250
0.7760
0.3330
0
As you see with the set ab, the numbers repeat itself:
0.3570
0.3560
0.3750
0.5150
and with second set ab:
0.4100
0.2500
0.3340
0.5500
0.6250
0.7760
0.3330
But also note that there is a zero at the end of the second set.
Now if I wanted to construct a vector using one set of data, I would use the following command for the second set to remove that zero
reshape(ab(1:end-1), [], 4);
This would read the vector from the first element to the last, being 0 and remove it with end-1. This also assumes that there are 4 runs.
Obviously this wouldn't work for the first set.
What would I need to change for this to read both sets and to prompt the user how many runs of data there are?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 24 de En. de 2013
Editada: Azzi Abdelmalek el 24 de En. de 2013
If you have just these two cases
if ab(end)==0
ab(end)=[]
end
out=reshape(ab,4,[])
  10 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 12 de Feb. de 2013
I guess because your ab becomes empty, to understand check this:
a=[];
if a(end)==0;
a(end)=[],
end
T
T el 13 de Feb. de 2013
Actually it would appear that the file in another directory didn't have any data at all!
How could I prompt the user to notify of such an occurence?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by