Hi everyone. My name is George and i am new to matlab. I need help to complete the following code, i am stuck. Please help.
1 view (last 30 days)
Show older comments
GEORGE WAYNE MWANGI
on 2 May 2017
Commented: Walter Roberson
on 2 May 2017
y=((-1/2)*g*t.^2)+(v*sind(x))*t
1 Comment
Walter Roberson
on 2 May 2017
This appears to relate to https://www.mathworks.com/matlabcentral/answers/338404-how-can-i-solve-this-problem-please-help
Accepted Answer
Walter Roberson
on 2 May 2017
Your x is length 201 or so. Your t is length 5. What size are you expecting v*sind(x))*t to be?
The * operator is algebraic matrix multiplication. In order for A*B to work, size(A,2) == size(B,1) . Your v*sind(x) is going to be about 1 x 201, and your t is 1 x 5, but 201 ~= 1
If you were to use t.' * (v*sind(x)) then that would be (1 x 5) transposed * 1 x 201, which would be 5 x 1 * 1 x 201, and that would be valid and give a 5 x 201 result. But then you would have trouble adding it to the 1 x 5 that is ((-1/2)*g*t.^2)
I suggest you consider
[X, T] = ndgrid(x, t);
y = ((-1/2)*g*T.^2) +(v*sind(X)) .* T;
0 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!