how to iterate?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
JULIET OSUNDE
am 7 Jan. 2021
Kommentiert: JULIET OSUNDE
am 7 Jan. 2021
Hello, I am new to matlab and in need of help. I have a 43200 x 2 matrix and having difficulty writting a code for this equation: Y=A+(D+C/2)*1, Z=Y-B. where A is -120449852, D=3311.5705, C=1476.9455, B=-10749852 from the data shown below.Please how do i code this in such a way that it repeats this operation for all the elements in the matrix sequentially and saves Z values for each iteration. for example, the next vaule of A=-107496428, D=1476.9455, C=-1719.7385 and B=-117996722 and so on...
Please note that data sample shown below is for first epoch,each epoch ends with zeros at the bottom, kindly bear this in mind while coding. Thanks
Data
-120449852 3311.5705
-107496428 1476.9455
-117996722 -1719.7385
-120627169 -1228.7064
-116870191 -3087.5875
-134480051 -125.6097
-125355131 3313.2842
-126744025 994.96613
-112248639 937.16468
-130631487 -3113.0687
-108469847 -191.42345
0 0
0 Kommentare
Akzeptierte Antwort
Stephen23
am 7 Jan. 2021
I don't see why any iterations are required, vectorized code will do this quite easily:
A = [-120449852, -107496428];
B = [-10749852, -117996722];
C = [1476.9455, -1719.7385];
D = [3311.5705, 1476.9455];
Y = A+(D+C/2)*1
Z = Y-B
5 Kommentare
Stephen23
am 7 Jan. 2021
M = [...
-120449852 3311.5705
-107496428 1476.9455
-117996722 -1719.7385
-120627169 -1228.7064
-116870191 -3087.5875
-134480051 -125.6097
-125355131 3313.2842
-126744025 994.96613
-112248639 937.16468
-130631487 -3113.0687
-108469847 -191.42345
0 0];
A = M(1:end-1,1);
B = M(2:end ,1);
C = M(1:end-1,2);
D = M(2:end ,2);
Y = A+(D+C/2)*1
Z = Y-B
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!