Hello everyone, i have 2 matrix A and B:
A (4X8):
0 0 0 0 0 1 0 0
0 0 1 1 1 0 1 0
0 1 0 0 0 1 0 1
1 0 1 0 0 1 0 0
B (4X3):
X1 Y1 Z1
X2 Y2 Z2
X3 Y3 Z3
X4 Y4 Z4
is it possible to create a new matrix like this?
C:
X4 Y4 Z4 X3 Y3 Z3 X2 Y2 Z2 X2 Y2 Z2 X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3
X4 Y4 Z4 X3 Y3 Z3
X4 Y4 Z4
i tried with this code but it creates a matrix with only 3 columns:
for k=1:8
C=B(A(:,k),:);
if ~(mod(k,1))
dlmwrite('file.txt',C,'-append');
READC=dlmread('file.txt') ;
end
end
Thanks!

댓글 수: 1

Jan
Jan 2018년 12월 14일
The question is not clear. What are "X1", "X2" etc.? Are they strings, symbolic variables or anyting else? The object C is not clearly defined. It cannot be a "matrix", because matrices need to have the same number of elements per row and colum. It is not clear, why you use dlmwrite and dlmread - is te indirection over the hard disk useful?
Please post valid Matlab code, which creates the inputs, and explain, which type the output should have.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2018년 12월 14일

댓글:

Jan
2018년 12월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by