How to load the data in this case?

As shown in the image there are two data sets 'a' and 'b'. How to load the data of 'b' into another variable, if a>0.1 and a<0.8?
Thanks
Thanks

 採用された回答

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015 年 5 月 29 日

0 投票

Hi,
Is that a excel file?! I don't get what you mean by loading.
If you just want to select some values do it like this.
c = a.*(a>0.1 & a<0.8);
So in variable c you will have what you want!

3 件のコメント

R7 DR
R7 DR 2015 年 5 月 29 日
編集済み: R7 DR 2015 年 5 月 29 日
Hi I loaded the data from excel to matlab. For example, I have the data like b=[ 1 2 3 4 5 6 7 8] a=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8]
now I have to load the data from 'b' to another variable 'c' if the values in 'a'>0.2 &<0.7. in this case; the c=[3 4 5 6 7]
Thanks
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015 年 5 月 29 日
編集済み: Salaheddin Hosseinzadeh 2015 年 5 月 29 日
So your data is already loaded into MATLAB. your question is not on how to load the data to MATLAB.
f = a.*(a>0.2 & a<0.7)
c = find(logical(f) == 1)
something like this should give you an answer
or
f = a.*(a>0.2 & a<=0.7) % if you also want 7 to be in c
c = find(logical(f) == 1)
R7 DR
R7 DR 2015 年 5 月 29 日
Hi Thanks..its working. But I have one more question.
How to modify the code if we have multiple variables. For example: 'b', 'c', 'd' and 'e' are the variables and the IF condition is same. Data is imported to matlab from excel.
In this case how to load the data from the specific variable for example:'e'
Thanks

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by