I am new to matlab and have a sample data(shown on pic) with many values inside. I need to multiply each values with its different conversion coefficient. How can I do that?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
CONV_COEFF = [0.0023394775; 0.0030514578; 0.0023394775; 0.0015258789; 0.0024414063; ...
0.0006103516; 0.0006103516; 0.0024414063; 0.0006103516; 0.0006103516; ...
0.0024414063; 0.0006103516; 0.0006103516; 0.0020345052; 0.0020345052; ...
1; 1; 0.0006103516; 0.00390625; 0.00390625; 0.00390625; 0.00390625; ...
1; 1; 1; 1; 1; 1; 0.00390625; 0.00390625; 0.00390625; 0.00390625; 0.00390625; ...
0.00390625; 0.00390625; 0.00390625; 1];
So for example, the value at 1 will need to multiply by 0.0023394775, value at 2 needs to mulitply by 0.0030514578, and so for.
I need to code to read this data from serial port and with the values I need to multiply each with its respective conversion coefficient. I need to run 100 samples.
Please help. :)
0 Kommentare
Antworten (1)
Sudhakar Shinde
am 6 Okt. 2020
Bearbeitet: Sudhakar Shinde
am 6 Okt. 2020
You could use 'serialport' and 'read' functions to read data from serial port.
for more info:
%Example reading 16 values
s = serialport("COM3",9600,"Timeout",5);
data = read(s,16,"uint32");
%Then use dot multiplication:
data.*CONV_COEFF
2 Kommentare
Siehe auch
Kategorien
Mehr zu Variables finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!