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.

please help to edit this matlab code

Status
Not open for further replies.

13maruf

Newbie level 6
Joined
Jan 18, 2011
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,350
a = 1:10;
b = a;
b(2,:)= [0, a(1: end-1)];
b(3,:)= [0, 0, a(1: end-2)];
B = b'

I want to generate this B matrix by a for loop...........please help me
 

The code which you wrote was a simpler one. See the code for generating B matric using for loop below:


b2(1)= 0;
b3(1)=0;
b3(2)=0;

for a =1:10
b1(a)=a;
if (a+1 < 11)
b2(a+1)= a;
end

if (a+2 < 11)
b3(a+2)= a;
end

end
B = [b1:)) b2:)) b3:))]



-sv
 

The code which you wrote was a simpler one. See the code for generating B matric using for loop below:


b2(1)= 0;
b3(1)=0;
b3(2)=0;

for a =1:10
b1(a)=a;
if (a+1 < 11)
b2(a+1)= a;
end

if (a+2 < 11)
b3(a+2)= a;
end

end
B = [b1:)) b2:)) b3:))]



-sv

what kind of a code is this???? There is no use of for loop !!! actually there is nothin to do with this code. If i just type B=[b1:)) b2:)) b(3:)] without any coding the result will be same...and what will u do if I say thet a=1:36???
 

If you want to use for a=1:36, change the n value in the code. I think now you can see the for loop in the code (I made it bold)

b2(1)= 0;
b3(1)=0;
b3(2)=0;
n = 10;

for a =1:n
b1(a)=a;
if (a+1 < n+1)
b2(a+1)= a;
end

if (a+2 < n+1)
b3(a+2)= a;
end
end
B = [b1:)) b2:)) b3:))]
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top