ich versuche derzeit die Hüllkurve über Sinussignale mit wechselnder Amplitude umzusetzen. Leider will es mir nicht gelingen. Technisch müsste ein Verlauf durch die Maximas interpoliert werden. Da ich in krasser Zeitnot stecke, wollte ich folgende Funktion aus dem Internet oder den Befehl abs(hilbert(x)) nutzen. Letzterer liefert mir nicht das gewünschte Ergebnis und für die Funktion erhalte ich nur Fehler.
signal ist ein Zeilenvektor mit diskreten Werten, ich verstehe nicht, was an meiner Eingabe falsch sein soll. Falls mir jemand einen Rat hat, wäre ich ihm sehr verbunden! Danke.
Code:
% Find upper and lower envelopes of a given signal % The idea is from Envelope1.1 by Lei Wang, but here it works well when the signal contains % successive equal samples and also includes first and last samples of the signal in the envelopes. % inputs: % sig: vector of input signal % method: method of interpolation (defined as in interp1) % outputs: % upperenv: upper envelope of the input signal % lowerenv: lower envelope of the input signal function[upperenv lowerenv] = envelope(sig, method) ifnargin == 1
method = 'linear';
end
upperind = find(diff(sign(diff(sig))) < 0) + 1;
lowerind = find(diff(sign(diff(sig))) > 0) + 1;
f = 1;
l = length(sig);
try
upperind = [f upperind l];
lowerind = [f lowerind l];
catch
upperind = [f; upperind; l];
lowerind = [f; lowerind; l];
end
xi = f : l;
upperenv = interp1(upperind, sig(upperind), xi, method, 'extrap');
lowerenv = interp1(lowerind, sig(lowerind), xi, method, 'extrap');
[EDITED, Jan] Bitte die Copyright-Bedingungen beachten, wenn Du im Forum fremden Code postest - Danke!
Die BSD-Lizenz ist zwar sehr großzügig, darf aber dennoch nicht einfach ignoriert werden.
Zitat:
Copyright (c) 2009, Omid
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
es sieht so aus, als habest Du eine lokale Variable, die ebenfalls "envelope" heißt. Dann wird diese statt der Funktion benutzt. Ich kann es gerade nicht ausprobieren, ob dies die gezeigte Fehlermeldung erzeugt, es wäre aber plausibel. Also:
danke für den Hinweis. Ich kam wegen der vielen Arbeit die Woche noch nicht dazu es zu probieren und habe wahrscheinlich einen Weg gefunden es zu umgehen. Nicht desto trotz werde ich es trotzdem probieren-für die Zukunft
Gruß Kilian
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.