I am very new to matlab and I don't know how to code this problem.I have two arrays: Debut and End. Each array contains doubles that indicates the start(Debut) or the end(End) of a certain period.I am doing some signal processing so I want all these periods be normalised. I am thinking of calculating the mean of all periods and then normalize each period to that mean ? or do you have any other ideas ?

 Akzeptierte Antwort

Aravind Ravikumar
Aravind Ravikumar am 20 Jun. 2019
Bearbeitet: Aravind Ravikumar am 20 Jun. 2019

0 Stimmen

MATLAB has a normalize function, you can view the documentation here. From your description of your problem, you can first calculate the mean of the arrays Debut and End element-wise and then use normalize() on the resultant array. For example, the following code does somewhat similar to what you want:
x = rand(1,10);
y = rand(1,10);
avg = (x+y)/2;
norm_avg = normalize(avg);
where x,y are 2 arrays, avg is the element-wise average of x,y and norm_avg is the result after using normalize() on avg.

6 Kommentare

Hinde essmahi BOUZIANE
Hinde essmahi BOUZIANE am 20 Jun. 2019
Is 'normalize' defined for input arguments of type 'double'?
Aravind Ravikumar
Aravind Ravikumar am 20 Jun. 2019
The first input argument of normalize(), ie. the object you need to normalize can have Data Types of double, single, table, timetable.
Also the input can be a vector, matrix, or a multidimensional array.
From the documentation,
N = normalize(A) returns the vectorwise z-score of the data in A with center 0 and standard deviation 1.
  • If A is a vector, then normalize operates on the entire vector.
  • If A is a matrix, table, or timetable, then normalize operates on each column of data separately.
  • If A is a multidimensional array, then normalize operates along the first array dimension whose size does not equal 1.
Data Types: double | single | table | timetable
Complex Number Support: Yes
Hinde essmahi BOUZIANE
Hinde essmahi BOUZIANE am 20 Jun. 2019
Actually I have an older version of matlab so 'normalize 'is not defined.
I tried this way:
Debut = Debut ./ max(Debut(:));
Fin = Fin ./ max(Fin(:));
But the problem is the difference somtimes is negative which was not the case before I normalized the two arrays.
How about finding the difference between Debut, Fin first, then dividing the resultant by max(resultant). For example,
x = rand(1,10);
y = rand(1,10);
diff = y-x;
res = diff ./ max(diff)
This should not produce any negative output because before normalizing every element is positive.
Hinde essmahi BOUZIANE
Hinde essmahi BOUZIANE am 20 Jun. 2019
I tought about too that but i need to use each element of the array in an other function ' arguments.
You could keep normalized values of each array separately in some other array, and to calculate normalized value of the difference you can use the original array.
x = rand(1,10);
y = rand(1,10);
diff = y-x;
res_nor = diff ./ max(diff)
x_nor = x ./ max(x)
y_nor = y ./ max(y)
Maybe something like the above code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Akshay Malav
Akshay Malav am 20 Jun. 2019

0 Stimmen

Hi , there is a inbuilt function in matlab to normalize the data . Look at the link mentioned below .
The function is V = normalize(A)
V will contain the normalized value of the array A

3 Kommentare

Hinde essmahi BOUZIANE
Hinde essmahi BOUZIANE am 20 Jun. 2019
s 'normalize' defined for input arguments of type 'double'?
Akshay Malav
Akshay Malav am 20 Jun. 2019
Yes it is defined for double also
Akshay Malav
Akshay Malav am 20 Jun. 2019
Ans also adding to above answer the normalize function ignores NaN values if it is present in your array

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by