MATLAB Matlab - matrix with blank space

AI Thread Summary
The discussion revolves around creating a specific output format in MATLAB using a predefined array. The user initializes a zero array of size 1x6 and assigns the value 2 to elements 2 through 4. However, there is a query regarding how to assign a negative value to the fifth element and retain a zero at the end, resulting in the desired output of "0 2 2 2 - 0." The conversation highlights the need for assistance in achieving this output format, particularly focusing on the correct syntax and methods in MATLAB for manipulating arrays and handling special characters like the negative sign.
Suvadip
Messages
68
Reaction score
0
r=zeros(1,6);
r(1,2:4)=2;
r(1,5)= -

rfor the above program,

I want the output as

r=

0 2 2 2 - 0

how to do this in matlab? please help
 
Physics news on Phys.org
suvadip said:
r=zeros(1,6);
r(1,2:4)=2;
r(1,5)= -

rfor the above program,

I want the output as

r=

0 2 2 2 - 0

how to do this in matlab? please help

cell array.

.
 

Similar threads

Back
Top