what will be the value of Variable must I put in this code to run it.pl help me out ?

function b = getByteSize(theVariable, returnType, fid)
% getByteSize returns the mem.usage of the provided variable(theVariable) to the given file
% identifier.
% returnType is assigned meaningfully according to the byte size if not stated
% Output is written to screen if fid is 1, empty or not provided.
s = whos('theVariable');
b = s.bytes;
if nargin == 1 || isempty(returnType)
scale = floor(log(b)/log(1024));
switch scale
case 0
returnType = 'byte';
% case 1
returnType = 'kb';
% case 2
returnType = 'mb';
% case 3
returnType = 'gb';
%case 4
returnType = 'tb';
case -inf
% Size occasionally returned as zero (eg some Java objects).
returnType = 'byte';
warning('Size occasionally returned as zero (eg some Java objects). Bytes assumed');
otherwise
%returnType = 'petabytes';
warning('Over 1024 petabyte. petabytes assumed');
end
end
switch returnType
case {'b','byte','bytes'}
b = s.bytes;
% case {'kb','kbs','kilobyte','kilobytes'}
b = b / 1024;
%case {'mb','mbs','megabyte','megabytes'}
b = b / 1024^2;
%case {'gb','gbs','gigabyte','gigabytes'}
b = b / 1024^3;
%case {'tb','tbs','terabyte','terabytes'}
b = b / 1024^4;
%case {'pb','pbs','petabyte','petabytes'}
b = b / 1024^5;
otherwise
returnType = 'bytes';
end
if nargin <= 2 || isempty(fid) || fid == 1
fprintf(1,[num2str(b) ' ' returnType '\n']);
elseif nargin > 2 && ~isempty(fid) && fid > 2
try
fprintf(fid,[num2str(b) ' ' returnType '\n']);
catch
warning(['fid(' num2str(fid) ') could not be edited. Hence the output will be written on the screen.']);
fprintf(1,[num2str(b) ' ' returnType '\n']);
end
[y,Fs]=audioread('handel143.wav');
file_read=resample(y,143,8192);
byte_size_of_sampled_signal=getByteSize(file_read);
file_open=fopen('file_read','r');
a=roundn(file_read,2);
b=zeros(1,2*length(a));
for sort_len=1:length(b)
if(sort_len>length(a))
b(sort_len)=a(sort_len-length(a));
else
b(sort_len)=a(sort_len);
end
end
to_sort=zeros(length(a),length(a));
for row_sort=1:length(a);
to_sort(row_sort,:)=b(row_sort:length(a)+row_sort-1);
end
[lexi_sorted_data,ind]=sortrows(to_sort);
encoded_data=lexi_sorted_data(:,length(a));
primary_index=find(ind==2);
out_data=[encoded_data',primary_index];
file_bwt=fopen('bwt.cmp','w');
fwrite(file_bwt,out_data,'uint8');
fclose(file_bwt);
s=out_data;
l=length(s);
uniquevalue = unique(s); % String s has all unique symbol sorted
lenvalue = length(uniquevalue);
f=zeros(1,lenvalue);
for h=1:lenvalue
f(h)=length(strfind(s,uniquevalue(h)));% Count the occurence of unique characters end
p=zeros(1,lenvalue);
for h=1:lenvalue
p(h)=f(h)/l ; % Probabilities for each unique character end
Entropy=0;
for h=1:lenvalue
Entropy = Entropy + (-p(h)*log2(p(h))); % Calculating the Entropy
end
end
end
symbols = unique(out_data) ;% Distinct data symbols appearing in sig
dict = huffmandict(symbols,p); % Create the dictionary.
hcode = huffmanenco(out_data,dict); % Encode the data.
plot(hcode,'g');
byte_Size_of_compressed_data=getByteSize(hcode);
disp('compression ratio');
CR=(byte_Size_of_compressed_data)/(byte_size_of_sampled_signal);
dhsig = huffmandeco(hcode,dict); % Decode the code.
symbols = (1:length(p)); % Distinct symbols that data source can produce
[dict] = huffmandict(symbols,p); % Create dictionary.
actualsig = randsrc(1,100,[symbols; p]); % Create data using p.
comp = huffmanenco(actualsig,dict); % Encode the data.
dsig = huffmandeco(comp,dict); % Decode the Huffman code.
isequal(actualsig,dsig)% Check whether the decoding is correct.
encoded_bwt_file=fopen('bwt.cmp','r');
dec_bwt_read=fread(encoded_bwt_file,'uint8');
fclose(encoded_bwt_file);
disp('BWT DECODING Started')
encoded_data=dec_bwt_read(1:length(dec_bwt_read)-1);
primary_index=dec_bwt_read(length(dec_bwt_read));
sorted_data=sort(encoded_data);
vector_flag=ones(1,length(encoded_data))';
vector=zeros(1,length(encoded_data))';
%%%%%%%preparing vector table
for h=1:length(sorted_data)
for j=1:length(sorted_data)
if(encoded_data(j)==sorted_data(h) && vector_flag(j))
% clc;
% encoded_data(j);
% sorted_data(i);
vector(h)=j;
vector_flag(j)=0;
break
end
end
end
index=primary_index;
reconst_data=zeros(1,length(encoded_data));
%getting original data back
for h=1:length(encoded_data)
reconst_data(h)=encoded_data(index);
index=vector(index);
end
rec_file=fopen('orig_file.txt','w');
fwrite(rec_file,reconst_data,'uint8');
fclose(rec_file);
disp('BWT Decoding over..')
disp('file written back as orig_file.txt')

 Risposta accettata

You need to move the part starting with the line
[y,Fs]=audioread('handel143.wav');
into a different file. The part before that must be stored in getByteSize.m

2 Commenti

Can you please elaborate this problem,actually I am not getting byte size of the result in KB,bytes etc.
thank you very much sir I got the answer .....

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by