Overwrite the same matrix passed into a function?

Hi, I have a function that edits some dates in a column to serial dates. How can I overwrite the matrix I pass into the function? When I run for example:
(dateMatrix) ----> new dateMatrix
But what happens is I get the ans matrix returned.
function A = changeDates(A)
d = A(:,1);
d=num2str(d)-0;
Y=str2num(char(d(:,1:4)));
M=str2num(char(d(:,5:6)));
D=str2num(char(d(:,7:8)));
sd=datenum(Y,M,D)
A(:,1) = sd;
clear d Y M D sd
thanks friz

 채택된 답변

bym
bym 2011년 5월 7일

0 개 추천

dateMatrix = changeDates(dateMatrix)

댓글 수: 2

friz
friz 2011년 5월 7일
thanks how could I forget that!
Matt Fig
Matt Fig 2011년 5월 7일
Also just so you know, there is no need to clear the function variables before the function exits. All simple variables defined in a function are destroyed automatically on exit.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

질문:

2011년 5월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by