v2 = [5; 2; 3];
I want now something like
v3 = [1 1 1 1 1 2 2 3 3 3];
So I could access my v1 vector with:
v1(v3==1);
c=cumsum(v2); v3=zeros(1,c(end)); v3([1,c(1:end-1)])=1; v3=cumsum(v3); v3(end)=[],
The cumsum(v2)
creates a cumulative sum vector c
.
A zero vector v3
is created with a length of the last value in c
.
Positions in v3
at 1
and c(1:end-1)
are set to 1.
Another cumulative sum is calculated over this v3
.
The last element of v3
is removed.
The result is a vector v3
that mirrors the cumulative structure of v2
but adjusted for the specific indexing manipulation.
This process transforms a cumulative indexing approach into a sequential one, useful in various signal processing or data transformation scenarios.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.