Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a09ef28
  • /
  • ExampleDownSample.m
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:ef4dcb82ab877c7488a71310ed343392abb21061
directory badge
swh:1:dir:a09ef28de3196ccfd7aac15c79dc54216cc697d7

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
ExampleDownSample.m
% This function opens a file and reads the data from a waveform channel as 32-bit floats. Then downsamples the data and saves it to a new file. It does not alter the orignal data.
% clear workspace
clear;
% add path to CED code
if isempty(getenv('CEDS64ML'))
    setenv('CEDS64ML', 'C:\path\to\your\folder\CEDS64ML');
end
cedpath = getenv('CEDS64ML');
addpath(cedpath);
% load ceds64int.dll
CEDS64LoadLib( cedpath );
% Open a file
fhand1 = CEDS64Open( 'C:\Spike7\Data\Demo.smr' );
if (fhand1 <= 0); unloadlibrary ceds64int; return; end

[ iOk, TimeDate ] = CEDS64TimeDate( fhand1 );

% get waveform data from channel 1
[ fRead, fVals, fTime ] = CEDS64ReadWaveF( fhand1, 1, 100000, 0 );

% downsample the data by a factor of 12
n = 12;
DSVals = fVals(1 : n : end); % selected every 12th element for the vector

% create a new file
fhand2 = CEDS64Create( '..\Data\ExampleDS.smrx' );
if (fhand2 <= 0); unloadlibrary ceds64int; return; end
% set the time base in the new file to be the same as in the original file
timebase = CEDS64TimeBase( fhand1 );
CEDS64TimeBase( fhand2, timebase );
% set the chan divide and ideal rates to be the same as the original file
chandiv = CEDS64ChanDiv( fhand1, 1 );
rate = CEDS64IdealRate( fhand1, 1 );
% create a new real wave channel
CEDS64SetWaveChan( fhand2, 1, n*chandiv, 9, rate/n );
% write filtered data to new channel
CEDS64WriteWave( fhand2, 1, DSVals, 0 );

% close all the files
CEDS64CloseAll();
% unload ceds64int.dll
unloadlibrary ceds64int;

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API