Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

matlab code for parallel to serial converter

Status
Not open for further replies.

abdullah gill

Member level 1
Member level 1
Joined
Mar 20, 2010
Messages
39
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
pakistan
Visit site
Activity points
1,503
function y=abc(x)
[r,c]=size(x);
a=[-1:c-2];
f=zeros(1,r*c);
for i=1:c
forj=1:r
f(i+j+a(i))=x(r,c-(i-1));
end
end
 

Try this Abdullah,

Assuming your Parallel stream of data is stored in a variable ParStream, then you can convert it into a serial stream as,

Code:
SerStream = reshape(ParStream,1,[])
 

thanks for the help but the problem is i have to use the code in system generator block so i cant use the inbuilt commands of matlab........can u help me in system generator
 

abdullah gill said:
thanks for the help but the problem is i have to use the code in system generator block so i cant use the inbuilt commands of matlab........can u help me in system generator

this is a very useful notation for me, it will help me in the nearest future. May be in the future i will use the FPGA board but for now, may be i can help in matlab, tell me with a numerical example how you want to convert?
for example:

Reshape a 3-by-4 matrix into a 2-by-6 matrix.

A =
1 4 7 10
2 5 8 11
3 6 9 12

B = reshape(A,2,6)

B =
1 3 5 7 9 11
2 4 6 8 10 12
B = reshape(A,2,[])

B =
1 3 5 7 9 11
2 4 6 8 10 12


or do you want your serial data (one dimension) to be in parallel (rows)?

tell me

thanks

Added after 43 minutes:

any way: i did this code for you:

%% parallel to serial
clc;
clear all;
close all;

a=[1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16;17 18 19 20]
r=length(a:),1))
aser=[];
for l=1:r
aser=[aser,a(l,:)];
end
aser


results:::::::

a =

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20


r =

5


aser =

Columns 1 through 14

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Columns 15 through 20

15 16 17 18 19 20


best regards
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top