Octave/MATLAB で、私が持っているとします:
all =
{
[1,1] = one
[1,2] = two
[1,3] = three
[1,4] = four
[1,5] = five
[1,6] = six
[1,7] = seven
[1,8] = eight
[1,9] = nine
[1,10] = ten
}
some =
{
[1,1] = someword
[1,2] = someword
[1,3] = one
[1,4] = someword
[1,5] = nine
}
次のような新しいマトリックスを作成するにはどうすればよいですか
new =
{
[1,1] = 1
[1,2] = 0
[1,3] = 0
[1,4] = 0
[1,5] = 0
[1,6] = 0
[1,7] = 0
[1,8] = 0
[1,9] = 1
[1,10] = 0
}
つまり、new
行列は行列と同じサイズですが、 の単語が?に存在するかどうかに応じてall
、値は1
またはのいずれかになります。0
some
all