フィルターのクリア

access to a element of a matrix

14 ビュー (過去 30 日間)
Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019 年 6 月 6 日
Basically I need to create a matrix of current values and access each element and call the same value in an equation.
I=[-40 -30 -20 -10 0 10 20 30 40];
w=0.035;
h=1.57;
% T=215.3*I^2*w^-1.5*h^-1 This the equation where I need to acces the I value each time from
  1 件のコメント
Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019 年 6 月 6 日
So how do I access it?

サインインしてコメントする。

採用された回答

Priysha Aggarwal
Priysha Aggarwal 2019 年 6 月 6 日
If you want to multiply each element of I matrix with some constant, you can directly do:
a = [ 1 2 3 4]
b = 2*a
% b = [2 4 6 8]
If you want to access each element in particular :
I=[-40 -30 -20 -10 0 10 20 30 40];
w=0.035;
h=1.57;
%iterate over I :
for c = 1:size(I)
a = I(c) %this will give you one element of I at a time
% now use T=215.3*c^2*w^-1.5*h^-1
end

その他の回答 (1 件)

pankhuri kasliwal
pankhuri kasliwal 2019 年 6 月 6 日
You can access elements of an array using
A = [1 2 3 4 5];
A(1);
if you have a matrix then you can access the elements using
a = [1 2 3;4 5 6;7 8 9]
a(2,3);
a(2,3) provides with the element 6 in 2nd row, 3rd column
T=215.3*I^2*w^-1.5*h^-1
instead of this you can do
T = 215.3 * (I .* I) * w^-1.5 *h^-1 ;
  1 件のコメント
Sachin Shridhar Bhat
Sachin Shridhar Bhat 2019 年 6 月 6 日
But I guess in this Iteration of 'I' dosen't happen

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by