how to subtract from every element in an array

I have a very large double array in which every element needs to have 300 subtracted from it due to a mis calibration how do i do this?

답변 (2개)

Jan
Jan 2015년 11월 3일
편집: Jan 2015년 11월 3일

5 개 추천

X = rand(100, 100); % Example data
Y = X - 300;
So, you see, it is as trivial as possible. Please note, that reading the Getting Started chapters from the documentation clears such questions efficiently.
Calum Yates
Calum Yates 2015년 11월 3일

0 개 추천

Will that subtract 300 from every individual element in the overall array then?

댓글 수: 2

Stephen23
Stephen23 2015년 11월 3일
편집: Stephen23 2015년 11월 3일
Try it and see! Your computer will not explode if you do a little experimentation:
>> [1,2;3,4] - 600
ans =
-599 -598
-597 -596
Or alternatively you could actually read the documentation for minus, which has an example of subtracting a scalar from a matrix, complete with the text "The scalar is subtracted from each entry of A."
Just a wild guess --- you didn't mean spatial calibration did you? Where your array (image) is misaligned and you want to shift it up, down, left, and/or right by 300 elements. If so, let me know.
By the way, you should respond as "Comments" rather than as a new independent "Answer" to your original question, unless your reply actually IS an answer to your original question.

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

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

질문:

2015년 11월 3일

댓글:

2015년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by