Code covered by the BSD License  

Highlights from
MAX WIDTH

1.0

1.0 | 3 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.49 KB File ID: #41046
image thumbnail

MAX WIDTH

by

 

01 Apr 2013 (Updated )

CALCULATING MAX WIDTH FROM A SERIES

| Watch this File

File Information
Description

HOW TO FIND IN A EASSY WAY THE MAXIM AND MINIM WIDTH IN A SIGNAL OSCILLATING FUNCTION

Required Products MATLAB
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
04 Apr 2013 Cesar Manuel Diez Chirinos

Well, somebody asked me this code, I just tried to design a good one, I find it very helpful maybe not for you. On the other hand some code likes correlation is not well clear and this is why I create my own codes. Thanks for comment I will consedire them. This is applied for Signals, if you never used signals you can try.

03 Apr 2013 Jan Simon

Now you have added a help text. Unfortunately this does not explain clearly, what the function calculates. At least I do not understand what "CALCULATE THE WIDTH ONE BY ONE AND CATCH THE BIGGER ONE" means.
The code seems like you want to calculate the minimal and maximal differences between neighboring elements. This can be done faster and simpler by:
dist = abs(diff(d));
[minValue, minIndex] = min(dist);
[maxValue, maxIndex] = max(dist);

The function is still not usable. Of course learning to use Matlab is done step by step only. But I do not see a reason to share such codes with others.

02 Apr 2013 John D'Errico

Note that:

- Fully half the code is commented out.
- It starts with a clear all, that is commented out, but is unnecessary in a function.
- There is NO documentation, except for the trivial line: "How does it work", which does not actually tell how it works!!!!!
- The line "for i = 1" effectively executes "i = 1", but takes more programming effort, and confuses things. Why add an end statement when none is needed?

%clear all;
function widthA(d)

%how does it work?
%widthA(d)
%d=[2 2 4 3 6 4 3 2 7 9 5 7 18];
% where d is your data
N=length(d);

%i=1;
%SD1 = d(:,i:N-1)
%SD2 = d(:,i+1:N)
%d1=SD1-SD2

for i = 1
SD1 = d(:,i:N-1);
SD2 = d(:,i+1:N);
d1=(abs(SD1))-(abs(SD2));
%corr(SD1(:,i:N-1),SD2(:,i:N-1))
%plot(ds)
end
df = max(d1)
%ad = min(d1)

[r,c,v] = find(d1==df);
%d1n = find(min(d1))
fl1=d(1,c)
fl2=d(1,c+1)

02 Apr 2013 Jan Simon

There is not useful explanation what this function should achieve. The code is hard to read also, e.g. lines like "for i = 1" are confusing only. The fact, that this function has no outputs shows, that this is neither useful nor usable.

Please cleanup this function substantially and add a help text - see other submissions for examples.

Updates
03 Apr 2013

Calculate the bigger width of a sinus series

03 Apr 2013

IF YOU HAVE ANY SIGNAL OSCILLATION, YOU CAN FIND THE BIGGER AND SHORTER SIGNAL OR WIDTH

Contact us