MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#" onclick="window._kiq.push(['set', { 'event': 'Turn off MT' }]);">ここ</a>」をクリックしてください。

0

Loop reading data into equation, store into array

Robert Guzek さんによって質問されました 2019 年 6 月 7 日
最新アクティビティ dpb
さんによって 回答されました 2019 年 6 月 10 日
I have imported in data that contains 5 columns and I would like to create a loop that will identify when the 5th column increases and decreases >2 points and will store the value of the 3rd column into A1 and the value of the 5th column into B1, then I want the loop to continue until the 5th column once again increases or decreases >2 points and repeat the process for A2 and B2 and then use those variables to calculate or C=abs(A1*B2+A2*B1). I want the loop to do this till the end of the imported data file and then store all the C's into an array.
Thank You

  2 件のコメント

dpb
2019 年 6 月 7 日
More than likely you don't need a loop--but you do need to precisely define what is meant by "when the 5th column increases and decreases >2 points". More than likely giving a short example dataset with inputs and expected outputs is the easiest way to explain this--and attaching a sample input data file saves folks from trying to recreate something from scratch.
Robert Guzek 2019 年 6 月 10 日
Hi,
So I have attached a sample dataset, the fifth column contains values ranging from about 30-50, so everytime that column increases or decreases by a value of 2 it will record the value of the third column in that row as R1 and the fifth column as T1 and then the next time the fifth column increases or decreases by a value of 2 the code will recognize the third column as R2 and the fifth as T2.

サインイン to comment.

1 件の回答

回答者: dpb
2019 年 6 月 10 日

data=importdata('yourfile.txt');
ix2=[false; abs(diff(ata(:,5)>=2))];
newdata=data(ix2,[3 5]);

  0 件のコメント

サインイン to comment.



Translated by