How to adjust data

2 次查看(过去 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

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by