Loading a zero array without setting as "empty"

조회 수: 3 (최근 30일)
SteveM
SteveM 2024년 2월 9일
댓글: Stephen23 2024년 2월 9일
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