mapping matrix of two vectors

조회 수: 6 (최근 30일)
Lama Hamadeh
Lama Hamadeh 2022년 4월 7일
댓글: Rajiuddin Sk 2023년 2월 1일
Hi,
If I have two vectors and as shown below. Is there a way to create matrix that mapps each row of A with its correspondent in B? In other words, check row by row of both A and B. Row 1 in A has the value of 1 and corresponds to value of 3 in B, then put one, otherwise put zero.
Thanks.

채택된 답변

Davide Masiello
Davide Masiello 2022년 4월 7일
clear,clc
A = [1;2;3;4];
B = [3;1;4;2];
C = A == B'
C = 4×4 logical array
0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0
  댓글 수: 1
Rajiuddin Sk
Rajiuddin Sk 2023년 2월 1일
Dear Davide,
When the matrix A and B contains symbols, then MATLAB could not find the transformation matrix in above mention method. Can you say how to find the transformation matrix in case of symbolic matrix?

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by