Hi, I am doing a really simple homework assignment:
"Create a file named matlabprog.m . In this program, you should create two arrays A and B. A should hold the numbers 1 through 4. B should hold the numbers 4 through 1.
You should then add A and B together, storing the result in a new array C.
After performing these array operations, you should use disp() to output the array (i.e. to output array C you would write disp(C); )
Then calculate sin(A) and store the resulting array in a new array named D. You should output array D using disp()
Each command should be on its own line and should end with a semicolon. Execute this file in matlab by typing the following into the prompt: >> matlabprog"
So this is what I did:
A = [1,2,3,4];
B = [4,3,2,1];
C = (A+B);
5 5 5 5
D = (sin(A));
0.8415 0.9093 0.1411 -0.7568
However, when I try to do the last step of the assignment of entering matlabprog into matlab, this comes up:
"Error: File: matlabprog.m Line: 5 Column: 12
Unexpected MATLAB expression."
So when I looked at the messages from my code these errors came up:
5 Parse error at 5: usage might be invalid MATLAB syntax.
9 Parse error at '0.9093': usage might be invalid MATLAB syntax.
How do I fix this, and is there anything else wrong with what I did? Thanks.