matlab


How to determine the index of a vector with range from 1


I have a question a the way to determine the index of a vector in matlab. Let see the my problem as the figure. I have a 6 bits that includes 2 parts: red part and blue part. Size of red part is |S1| and blue part is |S2|(ex: |S1|=2 and |S2|=4). The index of original bits (6 bits) from 0 to l . Now, I dumplicate the red part twice time and blue part 1 time to make the below bit with index from 0 to j. Size of red part is RF1*|S1| and blue part is RF2*|S2|. (ex: RF1=2 and RF2=1). Given a index in the below bits (from 0 to j), we can determine the index l of them in the original bit by the formula in the figure.
For example, If the index of a selected information symbol is, for example, 5, we map it to 5 mod 4+2=3 (red arrow)
However, the index of problem is from 0. As you know, the index of a vector in matlab will starts from 1. So I changes it as the below figure. My problem is that how to find index l if given index j it by matlab code using second scheme (index from 1). I done it but it looks complex
For index starts from 1, we can see that I want to map index j=6 to l=4
This is table example
This is my code
function l=find_index(j,S1,S2,RF1,RF2)
if j<(RF1*S1-1)
l=mod(j,S1);
if l==0
l=S1;
end
else
l=mod(j,RF2*S2)+S1 ;
if l==0
l=S2;
end
end
end
maybe this?
function l=find_index(j,S1,S2,RF1,RF2)
if j<=(RF1*S1)
l=mod(j-1,S1)+1;
else
l=mod(j-RF1*S1-1,S2)+S1+1;
end
end
Firstly S2 is always positive is it not? Which means that l=mod(d,RF2*S2)+S2 can never equal zero making the check that follows unnecessary. Secondly you can transform the first mod to include the check like so: l=mod(d-1,S1)+1; so putting it all togehter:
if j<(RF1*S1-1)
l=mod(j-1,S1)+1;
else
l=mod(j,RF2*S2)+S2;
end
which is probably the right answer without re-examining your logic (which I could not follow). However if for some reason you really really want a one liner:
l= (j<(RF1*S1-1))*(mod(j-1,S1)+1) + (j>=(RF1*S1-1))*(mod(j,RF2*S2)+S2);

Related Links

input size error in neural network programming by MATLAB
What does #() in front of a matrix?
feature map generation
' vectors must be the same length' error
the range of Theta & Phi angles in Spherical Coordinates matlab?
mask a portion of image in matlab?
visualise Orientation map with opencv or matlab
/usr/bin/ld cannot find lib files when compiling openCv matlab source
libfaad2.dll is not a valid win32 application - dependency error kernel32.dll
Moving a 3-D Object Along a Path in MatLab [duplicate]
Is there a way to subtract from spectrogram (stored as a figure) from another in MATLAB?
Matlab: generating a monte carlo sample from a defined model
Cuda matrix multiplication results differs from MATLAB
Clickable/ Interactive contour plots in Matlab
Writing a function such that it can be applied to a grid
MATLAB's 'solve,' applied to a system of equations, gives me a solution that doesn't satisfy one of the equations

Categories

HOME
robotframework
android-wear
fonts
jsonschema
linear-programming
saml
go-gorm
netbeans-8
http2
range
clion
google-maps-sdk-ios
pie-chart
asciidoc
sql-server-express
frequency
zend-expressive
google-cloud-sdk
postgresql-9.5
partitioning
accumulo
lazy-loading
spring-boot-admin
vast
appcelerator-alloy
ghost-blog
confidence-interval
trial
coqide
reformatting
mobile-center
nest-thermostat
spring-websocket
capstone
azure-app-service-envrmnt
sieve-of-eratosthenes
extraction
vue2
symfony-process
angularjs-routing
quicksand
win2d
sdcc
virtualmin
uifont
name-mangling
asyncsocket
xbrl
notimplementedexception
ganglia
master-data-management
tastypie
masspay
kie-workbench
sizing
android-sdk-tools
configuration-profile
mailcore2
hard-drive-failure
angular2-rc5
logstash-jdbc
hyperterm
cufft
network-traffic
mutation
jquery-load
pddl
pakyow
mysqladmin
hjson
windows-universal
cordova-cli
newsql
vraptor
scribe
bit.ly
laravel-validation
ratingbar
notifydatasetchanged
eventmachine
dojo.gridx
grunt-contrib-copy
azimuth
keymapping
android-c2dm
bochs
flash-cs4
visual-assist
asp.net-authentication
hudson-plugins
domain-mapping
android-actionbar-compat
datakey
google-website-optimizer
arr
undeclared-identifier
media-manager
adaboost
server.mappath
ladon
jetspeed2
exact-synergy-enterprise
replay
directoryentry
noaa
apache-config
n900
iequalitycomparer
newsgroup
plumtree

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App