Size doesn't match Value?

조회 수: 5 (최근 30일)
Theodore
Theodore 2023년 1월 20일
이동: DGM 2023년 1월 22일
I'm reading in a .mat variable, a column of numbers, which is appearing in my workspace as a "20,229 x 1 double"
I'd like to now create a for loop which loops x times (where x = 20,229), but when I go to find the size of the variable,
it shows as 25, not 20,229?
How do I properly extract this value for use? It is a column vector. Numel() or size() don't seem to work
  댓글 수: 2
Guilherme
Guilherme 2023년 1월 20일
Hi, Theodore!
Can you please share a extract of your code so that someone could try to figure out why it's not working?
Ideally you're trying to do something like this, right?
x = zeros(20000,1);
for i = 1:20000
% do your stuf
your_value = i;
x(i) = your_value;
end
numel(x) %% length(x) should prompt the same result. Size will have two informations: number of lines and number of columns.
Theodore
Theodore 2023년 1월 20일
Yes, apologies for blurring the variables (company confidentiality). 'Blue' and 'Purple' are equal length columns, each being read from a .mat file to have a size of '25'

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2023년 1월 20일
이동: DGM 2023년 1월 22일
You're finding the size of the char vector, not the variable.
myvariable = rand(100,1);
size(myvariable) % this is a 100x1 numeric vector
ans = 1×2
100 1
size('myvariable') % this is a 1x10 char vector
ans = 1×2
1 10

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by