see i am executing the code below

조회 수: 1 (최근 30일)
tina jain
tina jain 2015년 4월 7일
댓글: tina jain 2015년 4월 7일
close all;
clear all;
clc;
str=('ttttttPttttPPttt');
length=numel(str);
aa=estring(str)
zz=numel(aa)
comp_ratio=length/zz
------function estring-----------
function y = estring(str)
len = numel(str);
i = 0;
count = zeros(1,len);
y=[];
while( i<len )
j=0;
count(i+1) = 1;
while( true )
j = j + 1;
if( i+j+1 > len )
break;
end
if( str(i+j+1)==str(i+1) )
count(i+1) = count(i+1) + 1;
else
break;
end
end
if( count(i+1)==1 )
a=str(i+1);
length(a);
y = [y a];
i = i + 1;
else
a=str(i+1);
b=count(i+1);
y =[y a num2str(b)];
i = i + b;
end
end
end
I WANT TO KNOW THAT LENGTH/ZZ IS ACTUALLY CALCULATING COMPRESSION RATIO OR MY ASSUMPTION IS WRONG

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 4월 7일
Tina - length is a built-in MATLAB function so please don't use this as a variable name.
As for calculating the data compression ratio, your code seems appropriate. You have divided the uncompressed size by the compressed size which is similar to the same equation found elsewhere.
  댓글 수: 1
tina jain
tina jain 2015년 4월 7일
OK thank you Geoff Hayes

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by