0

I'm currently working on one mathematical algorithm on C, but I found a realization on matlab. The problem is that I don't know syntax. Can anybody explain me whats the meaning of this code?

[data(:,nt)'; zeros(nz-1,nx)]

nz, nx, nt are integers and data is a nx x nt matrix.

2 Answers 2

4

data(:,nt) means all rows (:) of column nt of the data matrix. The apostrophe (') means take the transpose of that.

zeros(nz-1,nx) means a matrix filled with zeros of size nz-1 x nx.

The [ ... ; ...] construct means vertical concatenation of the two matrices.

Sign up to request clarification or add additional context in comments.

Comments

1

Simon did most of the explaining, but remember that nt might be a matrix. Say nt = [1 2 3 1]. This would return columns 1, 2, 3 and 1 (anew), concatenated horizontally.

1 Comment

True in general but the OP did say that data is a nx by nt matrix which implies that nt is a scalar and which also implies that data(:,nt) could have also been written data(:,end).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.