Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Elementary Functions > matrixmanipulation > resize_matrix

resize_matrix

行列またはハイパー行列をトリムまたは拡張(およびキャスト)

呼び出し手順

resize_matrix // Demo

resMat = resize_matrix(mat, nbRows, nbCols)
resMat = resize_matrix(mat, nbRows, nbCols, resType)
resMat = resize_matrix(mat, nbRows, nbCols, resType, padding)
resMat = resize_matrix(mat, nbRows, nbCols,    ""  , padding)

resMat = resize_matrix(mat, newSizes)
resMat = resize_matrix(mat, newSizes, resType)
resMat = resize_matrix(mat, newSizes, resType, padding)
resMat = resize_matrix(mat, newSizes,    ""  , padding)

引数

mat

入力行列またはハイパー行列. 論理値, エンコードされた整数, 10進数 (実数または複素数), 多項式, またはテキストがサポートされます.

nbRows

大きさ変更後の行列の行数. 超過した行はトリムされます. 足りない行は拡張されます. Setting nbRows < 0 keeps the current number of rows.

nbCols

大きさ変更後の行列の列数. 超過した列はトリムされます. 足りない列は拡張されます. Setting nbCols < 0 keeps the current number of columns.

newSizes

matの各次元方向の新しい大きさを指定するベクトル. To keep a new size equal to the current one, just set it to -1.

size(mat)より短い場合, 1でパディングされます. 例: size(mat)==[ 4 3 3 2]となる mat が入力され, newSizes=[6 2]が指定された場合, newSizes = [6 2 1 1] が考慮されます.

newSizessize(mat)でなくなる場合, 新規次元が matに追加され,パディングされます. 例えば,size(mat)==[ 4 3 ]となるような matが入力され, newSizes=[6 2 2]が指定された場合, 結果は2ページのハイパー行列となります. 2番目の次元は完全にパディングされます.

newSizes = [nbRows, nbCols] は行列として使用できます.

padding

matと同じ型のオプションのスカラー, 次元方向に大きさが増加した際に作成された要素に設定する内容を指定します. デフォルトのパディングは 0 (実数または複素数10進数,エンコードされた整数,多項式), または "" (テキスト),%F (論理値)で行われます.

mat および padding の型が一致しない場合, scilabはpaddingの型を変換しようとします.

多項式の場合, パティングの変数名は強制的にmatと同じとなります.

resType

オプションのテキストで大きさが変更された行列が変換されるデータ型を指定します. "boolean", "constant", "string", "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", および "uint64" がサポートされます.

多項式およびテキストのハイパー行列については型変換がサポートされません.

resMat

大きさが変更され(変換され)た行列またはハイパー行列

説明

大きさ[nbRows, nbCols] または newSizesの行列, 大きさnewSizesのハイパー行列を作成します. 新しい大きさのある次元が最初のものよりも小さい場合, 行列はトリムされます. 大きさが増加した場合, 行列/ハイパー行列はパディングされます. 次元の数を増やすことも可能です. Scilabは自動的に大きさが1(シングルトン)に設定された最高の次元を縮小します.

結果の型は,上記の制限のもとにresType引数の指定により変更できます.

// 組込の例, 多項式を含む
resize_matrix

// 数値行列:
M = grand(4, 3, "uin", -9, 9)
resize_matrix(M, -1, 5)  //  use -1 to keep a size unchanged
resize_matrix(M, 2, -1)
resize_matrix(M, 3, 4)
--> M = grand(4, 3, "uin", -9, 9)
 M  =
  -8.  -5.  -2.
  -9.   0.  -1.
   4.  -1.   6.
   5.   1.   8.

--> resize_matrix(M, -1, 5)  //  use -1 to keep a size unchanged
 ans  =
  -8.  -5.  -2.   0.   0.
  -9.   0.  -1.   0.   0.
   4.  -1.   6.   0.   0.
   5.   1.   8.   0.   0.

--> resize_matrix(M, 2, -1)
 ans  =
  -8.  -5.  -2.
  -9.   0.  -1.

--> resize_matrix(M, 3, 4)
 ans  =
  -8.  -5.  -2.   0.
  -9.   0.  -1.   0.
   4.  -1.   6.   0.
resize_matrix(M, [3 4 2])
resize_matrix(M, [3 4 2], "", %i)
resize_matrix(M, [3 4 2], "string", %i)

// テキストの行列:
myMatString = ["Scilab", "the"; "Open Source", "Scientific"; "Software", "Package"]
resize_matrix( myMatString, 5, 3 )
// new sizesに等価な構文:
resize_matrix( myMatString, [5 3], "", "$" )    // カスタムパディング

// トリム, パディングとハイパー行列へのキャスト:
h = rand(2, 3, 2)*200
resize_matrix(h, [3 2 3], "int8")
resize_matrix(h, [3 2 3], "int8", -1)    // カスタムパディング
r = resize_matrix(h, [3 2 ] , "" , -1)   // 型変換せずにカスタムパディング
size(r)  // 最後の次元は縮小されました

// 多項式:
x = poly(0, "x");
P = (1-x)^grand(4, 2, "uin", 0, 3)
resize_matrix(P, 3, 3)
resize_matrix(P, [3 3 2])
resize_matrix(P, [3 3 2], "", %z)
//  => パディングの未知数はPのものに強制的に変更されました
//  => 多項式は変換できません

参照

  • matrix — ベクトルまたは行列を異なる大きさの行列に成形する
  • size — オブジェクトの大きさ
  • typeof — explicit type or overloading code of an object
  • double — converts inttype integers or booleans into decimal encoding
  • strtod — parse and convert literal numbers STRings TO Decimal numbers
  • string — 文字列に変換

履歴

バージョン記述
5.5.0
  • 多項式とハイパー行列を利用可能になりました.
  • カスタムパディングを指定可能となりました.
  • 新しい大きさをベクトルとして指定できます.
  • resize_matrix() に引数を付けない場合, 例(デモ)を表示します.
6.0.1 The resType option is extended to the new int64 and uint64 integer types.
Report an issue
<< pertrans matrixmanipulation squeeze >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:02:06 CET 2019