Hello everybody :
I have the following matrix of 6*6 elements
1 -2 1 1 -3 4 1 2 2 5 7 3 5 4 -7 -8 4 -8 -4 -1 -1 5 -7 7 1 -7 9 4 -2 1
I want to set condition for negative numbers and another condition for positive numbers and calculate a new matrix named B
B=zeros(size(A)) for i=1:numel(A)-1 for j=2:numel(A) if (A(i)<0) B(i)=2*sind(A(i)) else B(i)=1.5*sind(A(i))-2*tand(A(j)) end end end
The problem here is that I want to skip the last element of each row I mean :
i is not supposed to reach the last element of each row. it stops always at the before last element, j contrariwise can reach the last element, but the matrix B elements depends on i.
*1* *-2* *1* *1* *-3* ===> not supposed to be reached by *j* 4 1 2 2 5 7 3 5 4 -7 -8 4 -8 -4 -1 -1 5 -7 7 1 *-7* *9* *4* *-2* *1* ===> not supposed to be reached by *i*
I know that numel calculates for all the matrix elements and as I am writing, the code skips only the last element of the matrix and not every last element of a row ; so how to do, please ?
Best Answer