pick elements from an array

11 ビュー (過去 30 日間)
guru k
guru k 2020 年 3 月 9 日
コメント済み: Bhaskar R 2020 年 3 月 9 日
I am having a array like
a=0:.1:10;
if I want to extract the elements from .5 to 0.8 to a new array how to do it?
I tried with find matlab command but it is giving only the ffirst elemnet 0.5 in the new array. but I need from 0.5 to 0.8
Kindly help in this regard

回答 (1 件)

Bhaskar R
Bhaskar R 2020 年 3 月 9 日
new_a = a(a>=0.5 & a<=0.8);
  2 件のコメント
guru k
guru k 2020 年 3 月 9 日
Thank you. But my case is like this
x=[1:0.1:100];
y=x^2;
in this case if I need only certain data x and y range from x= .5 to x=0.8 and plot those x and y how to do?
I need array data of x and y for the range using index
kindly help in this regard
Bhaskar R
Bhaskar R 2020 年 3 月 9 日
y = x(x>=0.5 & x<=0.8).^2;
You are starting from 1 to 100 with 0.1 diff, it obviuos that output is empty

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by