Find a value in a matrix with specified interval
Show older comments
Hello all,
I have some problems with my matlab syntax. My goal: I'm trying to build a function where I can calculate the ristime out of my collection of data(matrix). For this I would like to search in a defined intervall for my 10 % Amplitude and 90% Amplitude. My Code:
function Risetime()
v = load('D:\MATLAB\Beispiele\Funktionen\Messkurve einer Entladung\C1MP1000000.dat');
t = v(:,1); %Read the values of time axis
a = v(:,2); %Read the values of amplitude axis
ai = a/0.1; % Calculate the current values
vi = [t ai]; % Build a Current Matrix
h = plot(t,ai);
hold all;
axis([-0.5e-7 1.5e-7 0 7]);
%Seeking for the upper limit
Imax = max(ai); % Imax oder Ip
[y zeile] = min(abs(ai - Imax)); % Die Zeile ermitteln
tmax = vi(zeile,1);
uL = [tmax, Imax]; % Upper Limit
I_10 = 0.1 * Imax; % Defining the Value for 10%
I_90 = 0.9 * Imax; % Defining the Value for 90%
% Suche der unteren Intervall Grenze min = [tmin, Imin]
% Leichteste Methode
% [tmin zeile] = find(t == tmin)
% Seeking for the lowest limit
tmin = 0;
[x zeile] = min(abs(t-tmin));
Imin = vi(zeile,2);
lL = [x, Imin]; %lowest limit
%Search for the Values for the values compared to I_10 and I_90 in the defined area of my matrix "vi"
for i = 1
ans = min(abs(vi(i,2)-I_10))
ans = find(uL < vi & vi < oL)
end
Now If I try to run my m file it gives me an error:
??? Error using ==> lt
Matrix dimensions must agree.
Error in ==> Risetime at 41
ans = find(uL < vi & vi < oL)
Could somone help me out!
Thank you!
Regards
Saqib Inam
1 Comment
Thomas
on 26 Apr 2012
Do you mean you want to find all your values of ai in vi which lie inbetween I_10 and I_90?
Accepted Answer
More Answers (0)
Categories
Find more on Programming 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!