I have 2 matrices path one is path which is 6x2 and sample8 which is 3X3. I want to extract an element from sample8 and put it in path as shown below:
path(i,1)=sample8(1,1)
When I do this I get no change in path Please help

3 件のコメント

Geoff Hayes
Geoff Hayes 2015 年 12 月 1 日
Ken - are you sure that this line of code is being executed? What happens if you put a breakpoint at this line and then run your code? When the debugger pauses at this line, look at the value for i, path before the update, sample8, and path after the update. Please describe the values for each of these two small matrices and perhaps include more of your code so that we can get an idea of what else is happening.
Ken
Ken 2015 年 12 月 1 日
編集済み: Walter Roberson 2015 年 12 月 1 日
Thanks Geoff. I a pasting my code and matlab output below:
path =
1 1
1 1
1 1
1 1
1 1
1 1
>> sample8
sample8 =
1 1 1
1 1 1
1 1 1
>> path(i,1)=sample8(1,1)
path =
1 1
1 1
1 1
1 1
1 1
1 1
Walter Roberson
Walter Roberson 2015 年 12 月 1 日
You are replacing a 1 with a 1. What output were you expecting?

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2015 年 12 月 1 日

0 投票

Has i been given a value?
>> path=rand(6,2); sample8=reshape(1:9,3,3)
sample8 =
1 4 7
2 5 8
3 6 9
>> i=2, path, path(i,1) = sample8(1,1)
i =
2
path =
0.999491620097705 0.100221540195492
0.287849344815137 0.178116953886766
0.414522538893108 0.35963491348208
0.464839941625137 0.0567046890682912
0.763957078491957 0.521885673661279
0.818204038907671 0.335848974676925
path =
0.999491620097705 0.100221540195492
1 0.178116953886766
0.414522538893108 0.35963491348208
0.464839941625137 0.0567046890682912
0.763957078491957 0.521885673661279
0.818204038907671 0.335848974676925

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Operating on Diagonal Matrices についてさらに検索

タグ

質問済み:

Ken
2015 年 12 月 1 日

編集済み:

2015 年 12 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by