How to adjust data
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Jan
on 11 Mar 2022
Edited: Jan
on 11 Mar 2022
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 Comments
Jan
on 11 Mar 2022
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
See Also
Categories
Find more on MATLAB Mobile Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!