Loading a zero array without setting as "empty"

3 次查看(过去 30 天)
Hi,
I am reading a data array (Data_Input) approx 32000 x 24 into 24 seperate arrays for easy plotting.
Firstly, I initialize each target array: (just one shown for simplicity):
app.Data1=zeros(number_of_rows,1,'double');
app.Data1 = app.Data_Input(:,4); This loads the 4th column from Data_Input into app.Data1, and works fine!
However, the problem is when app.Data_Input(:,4) (i.e. the 4th column) is full of zeros.
Then, instead of the initialized app.Data1 "zeros" matrix, I now have app.Data1 = empty !
This completely confuses my later APP software as it can't extract the "0" values from specific rows.
So how can I prevent a nicely formatted zeros matrix being converted to an "empty" matrix?
Please help,
Thanks
  5 个评论
Dyuman Joshi
Dyuman Joshi 2024-2-9
"I want seperate matrices as I need to perform other operations solely on one column."
That can be done via indexing as well.
"... runs faster if split into 24 separate matrices at the start."
I doubt that.
A simple approach would be to read the data, perform the operation on that particular column and then plot accordingly.
As I mentioned above and is explained thoroughly in the link I attached, splitting data into separate matrices is not considered to be a good idea.
Stephen23
Stephen23 2024-2-9
app.Data1
A cell array with indexing would still probably be better than 24 fields with pseudo-indices in their names.
@Dyuman Joshi: the code in the OP's question does not show 24 separate variables in the workspace (but apparently has 24 different fields of some app), so my tutorial is not directly related.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by