Normalising multiple columns of a matrix to a fraction of its maximum value

3 visualizzazioni (ultimi 30 giorni)
Data: Measurements of a bridge's natural frequencies / eigenfrequencies (master's degree, civil engineering)
1) Data set example (paint):
Notes:
a) f_1, f_2, f_3, f_n => natural frequencies [Hz],
b) a_i, b_i, c_i, n_i => displacement of i-th node / measuring point [mm],
c) there are always 21 measuring points => there are always 21 rows
d) measurements (data sets) are different => n is sometimes 5, sometimes 10, sometimes 15 but I need to analyze all data sets
2) Problem to solve (paint):
Notes:
a) a_i/a_max, b_i/b_max, n_i/n_max => fractions of maximum displacement [mm/mm=no unit]
Comment:
I need to write a code that would remake a matrix consisting of displacement values [mm] so it divides all values by the value's column's maximum value [mm/mm=no unit]. So in each column there should be exactly one number equal to 1,00. I know how to divide a whole matrix by a maximum value (of a matrix or just a row), but I have no idea how to divide each column by a different number. Complicated, I know. I need this for further calculations (comparing experimental and finite element method modal shapes).
Thanks in advance! I hope you liked my Paint talent :)

Risposta accettata

Voss
Voss il 20 Mag 2024
To divide each column by its maximum value:
data_normalized = data./max(data,[],1);
Example:
data = rand(21,5); % random data
data_normalized = data./max(data,[],1);
disp(data)
0.3794 0.8516 0.6192 0.9974 0.0485 0.5473 0.9512 0.3346 0.7293 0.3087 0.7468 0.8790 0.5080 0.3312 0.6452 0.1507 0.2931 0.9213 0.8985 0.8317 0.9915 0.1097 0.6171 0.5542 0.1940 0.4685 0.6239 0.4579 0.9900 0.1844 0.0630 0.8840 0.3104 0.5871 0.2056 0.1789 0.5089 0.1588 0.2956 0.6751 0.2515 0.0815 0.3480 0.3586 0.7300 0.4045 0.6555 0.6625 0.3284 0.6248 0.1053 0.6238 0.3821 0.0726 0.0529 0.9091 0.3172 0.9784 0.4816 0.8802 0.1635 0.8599 0.1088 0.6291 0.4188 0.0465 0.9600 0.4690 0.0528 0.3343 0.5934 0.2478 0.5415 0.7363 0.8638 0.9241 0.0415 0.9797 0.0765 0.9500 0.1802 0.7070 0.6599 0.7147 0.4607 0.9711 0.4433 0.7790 0.4921 0.0153 0.8528 0.8070 0.3096 0.7092 0.8844 0.2960 0.1858 0.3051 0.1203 0.8197 0.9482 0.7046 0.2076 0.3336 0.2242
disp(data_normalized)
0.3827 0.8870 0.6321 1.0000 0.0511 0.5520 0.9908 0.3415 0.7313 0.3249 0.7533 0.9156 0.5185 0.3321 0.6792 0.1520 0.3053 0.9404 0.9009 0.8756 1.0000 0.1143 0.6299 0.5556 0.2042 0.4725 0.6499 0.4674 0.9926 0.1941 0.0635 0.9208 0.3169 0.5887 0.2164 0.1804 0.5301 0.1621 0.2963 0.7106 0.2537 0.0849 0.3552 0.3595 0.7685 0.4079 0.6828 0.6763 0.3293 0.6577 0.1062 0.6497 0.3900 0.0728 0.0556 0.9170 0.3304 0.9987 0.4828 0.9265 0.1649 0.8957 0.1110 0.6307 0.4409 0.0469 1.0000 0.4787 0.0530 0.3519 0.5985 0.2581 0.5527 0.7382 0.9093 0.9321 0.0432 1.0000 0.0767 1.0000 0.1817 0.7364 0.6736 0.7166 0.4850 0.9794 0.4618 0.7951 0.4934 0.0161 0.8601 0.8406 0.3160 0.7111 0.9310 0.2985 0.1936 0.3114 0.1206 0.8629 0.9563 0.7340 0.2119 0.3344 0.2360
  2 Commenti
Nikodem Podlaszewski
Nikodem Podlaszewski il 23 Mag 2024
Modificato: Nikodem Podlaszewski il 23 Mag 2024
Hello, thanks for help. It works but I need to modify this function:
How can I modify this function to divide each column by its maximum or abs(minimum value), depending on:
if column's max value is greater than abs(min value), divide by maximum value,
if column's abs(min value) is greater than max value, divide my abs(min value)
I need to do it because I want each column to have values from -1 to 1
Thanks in advance
Voss
Voss il 23 Mag 2024
Modificato: Voss il 23 Mag 2024

To divide by max of max value and abs(min value), as you describe:

data_normalized = data./max(abs(data),[],1);

But that won't give you values from -1 to 1. If you want that, it would be:

mi = min(data,[],1);
ma = max(data,[],1);
normalized_data = (data-mi)./(ma-mi)*2-1;

Accedi per commentare.

Più risposte (1)

Catalytic
Catalytic il 21 Mag 2024
Data=normalize(Data,1,'norm',inf)
  1 Commento
Nikodem Podlaszewski
Nikodem Podlaszewski il 23 Mag 2024
Hello, thanks for help. I need to modify this function:
How can I modify this function to divide each column by its maximum or abs(minimum value), depending on:
if column's max value is greater than abs(min value), divide by maximum value,
if column's abs(min value) is greater than max value, divide my abs(min value)
I need to do it because I want each column to have values from -1 to 1
Thanks in advance

Accedi per commentare.

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by