How to write the matrix with blank element?
显示 更早的评论
for i=1:10
if i~=6 T(i)=2*i
else T(i)= %(i want to leave it blank) end end
T
Is this possible in Matlab? If yes, How to do this?
2 个评论
suvadip paul
2013-10-4
Rohit Deshmukh
2020-2-28
is there any possibility of keeping the element blank?
I do not want nan or ND nor do i want to delete the element from matrix.
采纳的回答
更多回答(3 个)
Vidhya Dharshini
2013-10-4
Hi... try this
for i=1:10
if(i~=6)
T=2*i
else
T='ND'
end;
T
end
just give T='ND' and it will display.
1 个评论
Image Analyst
2013-10-4
But you're overwriting T every time, plus sometimes it's a double and other times it's a character string.
Thanks for getting back to me!
Like @Rohit Deshmukh, I would like to have blank elements in my vector (or maybe it's a "datetime array"?)
I'm plotting millions of lines of data in monthly chunks. For my plots I want xticks for every day but xtick labels only every other (second) day. In other words I want minor tickmarks every day, and major tickmarks every other day (I know there is the XMinorTick 'on' option, but I haven't figured that out yet so I'm also trying this strategy).
Below, I'm trying to include these blanks in my array, but instead of reading datetime([],[],[]) as a physical blank space, it just skips over it, leaving me with only the major tickmarks.
% data is collected every minute
timestartm = datetime(2022,02,01);
timeendm = datetime(2022,02,28);
xlimit = [timestartm timeendm];
xtki = 2; % xtick interval is 2
xtkl = [(timestartm) (datetime([],[],[])) (timestartm + xtki) (datetime([],[],[])) (timestartm + 2*xtki)...
(datetime([],[],[])) (timestartm + 3*xtki) (datetime([],[],[])) (timestartm + 4*xtki) (datetime([],[],[]))...
(timestartm + 5*xtki) (datetime([],[],[])) (timestartm + 6*xtki) (datetime([],[],[]))...
(timestartm + 7*xtki) (datetime([],[],[])) (timestartm + 8*xtki) (datetime([],[],[]))...
(timestartm + 9*xtki) (datetime([],[],[])) (timestartm + 10*xtki) (datetime([],[],[]))...
(timestartm + 11*xtki) (datetime([],[],[])) (timestartm + 12*xtki) (datetime([],[],[]))...
(timestartm + 13*xtki) (datetime([],[],[])) (timestartm + 14*xtki) (datetime([],[],[]))]
Image Analyst
2022-7-14
0 个投票
You're posting this as an "Answer" to a question that people can see (by the green box) that has already been successfully answered. So many people will not open this and look at your question. Again it's best if you start a new question - not anywhere here in this discussion thread, but a brand new question all your own. More people will see it and answer it then.
If you can mock up some desired output, whether it's some numbers or a picture of something you drew in Photoshop, such as a plot or whatever. But people need to see what you'd like to achieve as a solution.
1 个评论
Ruben
2022-7-18
Oh I understand now. Thanks for explaining that to me and sending me the tutorial.
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

