Filter löschen
Filter löschen

How to adjust data

3 Ansichten (letzte 30 Tage)
Dirk te Brake
Dirk te Brake am 11 Mär. 2022
Kommentiert: Jan am 11 Mär. 2022
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?

Antworten (1)

Jan
Jan am 11 Mär. 2022
Bearbeitet: Jan am 11 Mär. 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 Kommentare
Dirk te Brake
Dirk te Brake am 11 Mär. 2022
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 am 11 Mär. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Construction finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by