필터 지우기
필터 지우기

Storing data in another array

조회 수: 3 (최근 30일)
Matlabhelp
Matlabhelp 2016년 9월 29일
댓글: Image Analyst 2020년 8월 25일
Hello
I'm trying to store data in a separate array and was wondering how to do so, an example of my cod will be down below. My data is a 20x20 array of numerical values. What i've achieved is rounding the data in my array to 2 decimal places, but i dont know how to store the newly rounded data in a separate array. How do i create another array the same size and store the newly rounded data in there?
mydata = dlmread('data-1.csv',',');
MAX_ROWS = size(mydata,2);
MAX_COLUMNS = size(mydata,1);
% Rounding data to two decimal places
for r = 1:MAX_ROWS
for c = 1:MAX_COLUMNS
mydata(r,c);
round(mydata,2);
errorMap(r,c);
end
end
  댓글 수: 1
Image Analyst
Image Analyst 2020년 8월 25일
Original question in case he deletes it like the other posts:
Hello
I'm trying to store data in a separate array and was wondering how to do so, an example of my cod will be down below. My data is a 20x20 array of numerical values. What i've achieved is rounding the data in my array to 2 decimal places, but i dont know how to store the newly rounded data in a separate array. How do i create another array the same size and store the newly rounded data in there?
mydata = dlmread('data-1.csv',',');
MAX_ROWS = size(mydata,2);
MAX_COLUMNS = size(mydata,1);
% Rounding data to two decimal places
for r = 1:MAX_ROWS
for c = 1:MAX_COLUMNS
mydata(r,c);
round(mydata,2);
errorMap(r,c);
end
end

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

채택된 답변

Stephen23
Stephen23 2016년 9월 29일
편집: Stephen23 2016년 9월 29일
Why do you need all of those loops? There is no point in making your code much more complicated than it needs to be:
mydata = dlmread('data-1.csv',',');
newData = round(mydata,2);
For learning very basic MATLAB operations, such as how to assign a value to a new variable, you should do the (free!) introductory tutorials:
  댓글 수: 3
Stephen23
Stephen23 2016년 9월 29일
편집: Stephen23 2016년 9월 29일
@Wilhelm Concha: MATLAB is not "other programs". Learn to use it, not fight it:
If my answer resolved your question, then please accept it.
Matlabhelp
Matlabhelp 2016년 9월 29일
To easy, cheers mate

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by