I want compare the differences from each block of 10 values to the next block of 10 values until the given 100 sets of values are compared.

1 回表示 (過去 30 日間)
I want to compare first 10 data with the next 10 data using a while loop. I have coded for first 10 values and have obtained the plot. In the same way I need to obtain it for next 10 sets of values until 100 sets of values are completed. For this I need to code using i,j values something in this format x = a(j:j+1). Please help me with this code
clc;
close all;
x = a(1:11)
while n < 12
y(n) = a(n) - a(n-1);
n = n + 1
end
plot(y)
  4 件のコメント
Image Analyst
Image Analyst 2022 年 8 月 29 日
@Surabhi A S did you try, or even see, @Jan's answer below? Scroll down.
Surabhi A S
Surabhi A S 2022 年 8 月 29 日
Yes I saw it. But I haven't tried it yet. I'll try it once

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

回答 (1 件)

Jan
Jan 2022 年 8 月 23 日
編集済み: Jan 2022 年 8 月 23 日
According to the text of the question (but not the posted code):
A = rand(100, 1);
B = reshape(A, 10, 10);
C = diff(B, 1, 1);
plot(C)
while-loops are useful if the limits are determined dynamically. Use a for-loop for known limits or a “vectorised” approach using arrays as above.
  10 件のコメント
Surabhi A S
Surabhi A S 2022 年 9 月 14 日
@Jan Thank you for your efforts. Let's make a last try if you can understand it by this flowchart what I exactly want else no problem.
Jan
Jan 2022 年 9 月 15 日
@Surabhi A S: You ignore my questions for clarificationsm but introduce new information ("Z positive for more than 5 points"), which do not match the formerly given details. The instruction "fall is detected" is not clear.
Of course I could try to guess, what you want, but this is neither efficient nor trustworthy.
Before you can write a program, you need a clear and clean idea of what you want to achieve.

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

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by