Here is a sample code that demonstrates the computation of a scalar s:
main.m275 chars17 lines
The code first defines two arrays x and y. Then, it initializes the scalar s to 0. It then loops through each element of x and y, and checks if x(i) is greater than y(i). If it is, then it adds x(i) to the scalar s. Finally, it displays the value of s.
Note that you can replace the sample data with your own arrays to compute the sum of elements satisfying the specified condition.
gistlibby LogSnag