mat1(mat2) = mat1 assignment.

1 view (last 30 days)
li
li on 26 Jun 2022
Answered: li on 26 Jun 2022
How does the mat1(mat2) = mat1 assignment work given two one dimensional arrays like so:
ThemeCopy
t1 = [ 0 1 2 3 4 5 6 ];
t2 = [ 7 6 5 4 3 1 1 ];
t1(t2)=t1
t1 = 1×7
6 1 4 3 2 1 0
What is the "pattern"? - and how would you implement something like this in C++/pseudo code?

Accepted Answer

li
li on 26 Jun 2022
模式是微不足道的。我不明白,不清楚的是:
主题复制
t1 = [ 0 1 2 3 4 5 6 ];
t2 = [ 7 6 5 4 3 1 1 ];
t1(t2) = t1;
% 明确:
t1([7 6 5 4 3 1 1]) = [0 1 2 3 4 5 6];
t1 的第 7 个元素设置为 0,第 6 个元素设置为 1,第 5 个元素设置为 2,依此类推。t1 出现在左侧和右侧并不重要。它的执行方式如下:
主题复制
tmp = 零(1, 7);
tmp(t2) = t1;
t1 = tmp;

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by