Conditional in values of a matrix
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Montserrat Vallcorba Martí
am 30 Nov. 2017
Kommentiert: Star Strider
am 1 Dez. 2017
Hi,
I want to do the following condition in a matrix:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170474/image.jpeg)
The example:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170476/image.jpeg)
Any suggestion?
Thank you!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Star Strider
am 30 Nov. 2017
Your original description of the problem contains an error.
In order to get ‘Vector B’, you need to divide ‘abs(A(i,3))’ by 100.
This works, and gives the correct result:
A = [0.08 -0.335 75; 0.017 -0.335 75; 7.17 0.468 38.5; 19.33 1.379 29; 150 3.73 20];
B = A(:,2)-A(:,3).*abs(A(:,2))/100;
B(A(:,2)<0) = A(A(:,2)<0,2)
B =
-0.3350
-0.3350
0.2878
0.9791
2.9840
2 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!