필터 지우기
필터 지우기

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 CenterFile Exchange에서 Construction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by