You can use the for loop and the sum function in MATLAB to sum all values of t and x. Here's an example code:
main.m126 chars10 lines
In this example, t and x are arrays with 5 elements each. The for loop iterates through the array indices using the length function to control the number of iterations. The sumtot variable is initialized to zero before the loop begins. Inside the loop, each element of t and x is added to sumtot using the addition operator (+). Finally, the disp function is used to display the resulting value in the command window.
You can modify this code to work with your own arrays of t and x.
gistlibby LogSnag