フィルターのクリア

How to find out an element from a array when I have given some condition and rest of the elements will strore in different file as it is not obey the condition.

2 ビュー (過去 30 日間)
AS
AS 2019 年 1 月 16 日
回答済み: s 2019 年 1 月 17 日
Suppose I have matrix A=[ 1 4 5 88 34 9 10 3 45 12], I have given the condition that if A<=10, then element will sotre with row and column in new file and else rest of the element will store in different file.

回答 (2 件)

s
s 2019 年 1 月 16 日
編集済み: s 2019 年 1 月 16 日
A=[ 1 4 5 88 34 9 10 3 45 12];
B = A < 10;
C= A(B)
D =A(~B)
C =
1 4 5 9 3
D =
88 34 10 45 12
This should store the results in different matrices.
  2 件のコメント
AS
AS 2019 年 1 月 17 日
Thank you very much for your answer. I accept your answer which is only applicable on this example only. In real case, I have a data with 30 rows and 100 columnns. And in this data, I want separate the values whivh are less thta 0.01 and also want to store it in a new file. And rest of the values i.e. those are greater than 0.01, want to separate form previous and also want store it another file. In this case, your answer is not working....
s
s 2019 年 1 月 17 日
Can you mention the error message?
clc;
close all;
clear all;
A=[0.006 0.001 3 4 0.005;6 7 0.008 9 10]
B = A<0.01
C = A(B)
D = A(~B)
matlab.io.saveVariablesToScript('New_File1.m','C')
matlab.io.saveVariablesToScript('New_File2.m','D')
The above code works for me.

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


s
s 2019 年 1 月 17 日
clc;
close all;
clear all;
A=[0.006 0.001 3 4 0.005;6 7 0.008 9 10]
B = A<0.01
C = A(B)
D = A(~B)
matlab.io.saveVariablesToScript('New_File1.m','C')
matlab.io.saveVariablesToScript('New_File2.m','D')
The above code works for me.

カテゴリ

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