フィルターのクリア

How to adjust data

3 ビュー (過去 30 日間)
Dirk te Brake
Dirk te Brake 2022 年 3 月 11 日
コメント済み: Jan 2022 年 3 月 11 日
I have some data form the height of a waterrocket. I want to compare them using a graph but not all the data starts at the same height so i want to lower the graph so that x0=0 and y0=0. I believe this should do the trick:
Yaxis = [11:1:20] % Some data
Yaxis = Yaxis-Yaxis(1,1) % Subtract the first number form every point on the graph
And when i run this in the Command Window it works but when i implement this in my function it doesnt work, what is wrong?

回答 (1 件)

Jan
Jan 2022 年 3 月 11 日
編集済み: Jan 2022 年 3 月 11 日
A bold guess: Maybe because you overwrite Yaxis(1,1) before?
Yaxis(1,1) = Yaxis(1,2);
Yaxis = Yaxis-Yaxis(1,1);
Simplify your code. E.g.:
i = 2;
Yaxis = data. data(2,9); %zet een begin waarde voor B en data. data(1,9) kan hier niet gebruikt worden omdat dit een extremen waarde is
while i < Rowcount %Dit moet nog verbetert worden want nu moet handmatig opzoeken hoe veel metingen de sensor heeft gedaan
A = data. data(i,9) - data. data(2,9); %Omdat de sensor niet altijd op nul begint berekent dit stuk eerst het verschil tussen de waarde
Yaxis = [Yaxis A]; %Maakt een array van het verschil
i = i + 1; %Verhoogt i zodat de while loop continued
end
% Simpler without a loop:
Y = data.data(:, 9);
Yaxis = [Y(2), Y(2:end) - Y(2)];
  2 件のコメント
Dirk te Brake
Dirk te Brake 2022 年 3 月 11 日
After i tried to use the code you suggested i cant get my code to run. I keep getting the error:
Undefined function 'Dataselectie' for input arguments of type
'char'.
Maybe you know how to fix this?
Thank you for trying to help.
Jan
Jan 2022 年 3 月 11 日
The file Dataselectie.m must be visible for Matlab: either it must be inside the current folder or inside a folder, which is part of Matlab's path. See:
doc path
doc addpath

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by