Matlab - matrix with blank space

  • Context: MATLAB 
  • Thread starter Thread starter Suvadip
  • Start date Start date
  • Tags Tags
    Matlab Matrix Space
Click For Summary
SUMMARY

The discussion focuses on creating a MATLAB matrix that includes a blank space represented by a dash (-). The user initializes a row vector with zeros and assigns the value 2 to specific indices. To achieve the desired output of the matrix displaying a dash in the fifth position, the solution involves using a cell array to accommodate mixed data types. The final output format is confirmed as r = [0 2 2 2 - 0].

PREREQUISITES
  • Basic understanding of MATLAB syntax and matrix operations
  • Familiarity with cell arrays in MATLAB
  • Knowledge of indexing in MATLAB
  • Experience with MATLAB's data types
NEXT STEPS
  • Explore how to create and manipulate cell arrays in MATLAB
  • Learn about MATLAB's indexing techniques for matrices
  • Investigate how to display mixed data types in MATLAB outputs
  • Study MATLAB's data type conversion methods
USEFUL FOR

MATLAB users, data analysts, and anyone looking to manipulate matrices with mixed data types in MATLAB.

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

  • · Replies 4 ·
Replies
4
Views
4K
Replies
6
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K