Reputation: 3
So i have this code which goes like:
a = 51.50:0.001:51.51;
b = -2.55:0.238:-0.17;
c = 1000
p1 = [a(:),b(:)]
Now if you run this code, it'll give column 1 with all the 'a' components and column 2 with 'b' components. Is it possible anyway to get matlab to give me back the components like:
p1 = (a1,b1) p2 = (a2,b2) ..... and so on where a1 and a2 are first components of a and same for b. means in sets of twos. like x and y components.
Another thing, also for the same code, is it possible to insert a third column, lets say 'c', with all the components as 1000? Thanks
Upvotes: 0
Views: 33
Reputation: 112659
First question: once you have your p1
variable, simply use p1(1,:)
, p1(2,:)
etc.
Second question: use
c = 1000*ones(1,size(p1,1)); %// define vector c as needed, with appropriate size
p1 = [p1, c(:)];
Upvotes: 1