フィルターのクリア

How to specify a row and column in an array

4 ビュー (過去 30 日間)
HC98
HC98 2021 年 6 月 16 日
回答済み: KSSV 2021 年 6 月 16 日
So I have a 5x80 array and want to write a section of code which subtracts row 1, column 1 from row 2 column 1. How might I do that? I already tried using the (x,:) technique.
This is my attempt:
u1 = u(1,:1);
u2 = u(2,:1);

回答 (1 件)

KSSV
KSSV 2021 年 6 月 16 日
A = rand(5,80) ;
iwant = A(1,1)-A(2,1)
What you tried:
u1 = u(1,:1);
:1 is not valid. Simply you need to index bu u(r,c).
u(1,:) % gives entire first row
u(:,1) % gives entire first column

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by