Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
how can we compare two arrays eg 'data' and 'aa' ,when 'data' matches any value of 'aa' i want it to return past values of data that are before that common value of data and aa....in an array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
clc
close all
clear all
[data, fs]=audioread('E:\MATLAB\R2017a\examples\audio\focus_good.wav');
sound(2*data,45000)
aa = [0, 0.0001, 0.0002, 0.0003, 0.0004];
u=data(:); % reshape
for i=1:length(u)
for j=1:length(aa)
if data(i)==aa(j)
s=i % saving the point or number of digit where value matched
*q=data(0:i)* % wanted to return past value but not working**
else
end
end
end
i am having the problem in returning past values, you can check the asterick command in code... please help me out.
0 Kommentare
Antworten (2)
Walter Roberson
am 23 Mär. 2018
ismember(aa, dd), take the second output, index it at the first output, take the min() of the result. That will be the index of the first entry in dd that was in common so return everything in dd before that index.
1 Kommentar
Walter Roberson
am 25 Mär. 2018
[tf, idx] = ismember(aa,dd);
result = dd(1:min(idx(tf))-1);
Birdman
am 23 Mär. 2018
tempRes=setdiff(aa,data) %temporary solution, will be changed
[~,idx]=ismember(aa,data)
[~,idx]=max(idx)
tempRes(aa(idx):end)=[]
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!