row of all 8’s
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Suppose O=ones(n) Now how can I insert a row of all 8’s between rows (n-3) and (n-2) of matrix O and insert a column of all 8’s between columns 1 and 2 of matrix )
採用された回答
Kaushik Lakshminarasimhan
2017 年 11 月 23 日
編集済み: Kaushik Lakshminarasimhan
2017 年 11 月 24 日
N = 10;
X = ones(N); % create a matrix of 1s
X = [X(1:N-3,:) ; 8*ones(1,N) ; X(N-2:end,:)]; % add a row of 8s between (N-3)th and (N-2)th row
X = [X(:,1) 8*ones(N+1,1) X(:,2:end)]; % add a column of 8s between 1st and 2nd columns
9 件のコメント
Chung Di
2017 年 11 月 23 日
Error: File: ones.m Line: 4 Column: 15 Expression or statement is incorrect--possibly unbalanced (, {, or [.
Kaushik Lakshminarasimhan
2017 年 11 月 23 日
Can you show us your code?
Chung Di
2017 年 11 月 23 日
Have tried same as you, Nothing changed
Chung Di
2017 年 11 月 23 日
This one
Walter Roberson
2017 年 11 月 24 日
Copy and paste Kaushik Lakshminarasimhan's code. Spacing is important.
Chung Di
2017 年 11 月 24 日
Where is the fault ? I tried his code
Kaushik Lakshminarasimhan
2017 年 11 月 24 日
There should be no space between X and the parenthesis in X(1:N-3,:).
Chung Di
2017 年 11 月 24 日
It will be really helpful if you use comments beside the code, so that I can understand the code, rather than copy paste Thank you so much
Kaushik Lakshminarasimhan
2017 年 11 月 24 日
I didn't add comments because I thought it was self-explanatory. Anyway, I have edited my answer to include comments.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Multidimensional Arrays についてさらに検索
参考
2017 年 11 月 24 日
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
