Creating an array which has the linear index of the element left of each position.
5 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to use MATLAB functions to creating a 9x11 array which has the linear index of the element left of each position that replaced the undefined variables with 0's. Currently I have the code to create it as a 9x10 array but am not sure how to include the row of 0's for the undefined variables to make it a 9x11 array using functions. Any help would be very much appreciated.
clearvars
clc
close all
L = reshape(1:90,9,10);
L(1,:) = zeros(1,1);
0 件のコメント
採用された回答
Walter Roberson
2022 年 10 月 15 日
I am not clear as to what you want to do, but
L = reshape(1:90,9,10);
L = [zeros(size(L,1),1), L]
1 件のコメント
Walter Roberson
2022 年 10 月 15 日
A different approach
L = reshape(1:90,9,10);
L(:,end+1) = 0;
L = circshift(L, [0 1])
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!