I receive different output to like input
1 view (last 30 days)
Show older comments
why is there diffrent in the outputs?
![v=0:4;[0:4+5*(0:4)'];[v+5*v']](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1176283/v=0:4;[0:4+5*(0:4)'];[v+5*v'].png)
1 Comment
Gautam Chettiar
on 1 Nov 2022
v' is the transpose, and when you are adding two 1-D arrays which have different dimensions, here of (1,5) and (5,1), MATLAB automatically casts a broadcasted matrix addition, hence both of matrices get converted to (5,5) dimension form with repeating columns and rows respectively. The output is exactly what it should be.
Accepted Answer
Voss
on 1 Nov 2022
0:4+5*(0:4)' is the same as 0:(4+5*(0:4)')
0:(4+5*(0:4)')
v+5*v', where v is 0:4, is the same as (0:4)+5*(0:4)'
v = 0:4;
v+5*v'
(0:4)+5*(0:4)'
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!