Help regarding Use of basic loop in matlab
Help regarding Use of basic loop in matlab
(OP)
Hi everybody,
At present, I am learning to work with matlab. I want to learn how to implement a basic loop for the following steps I perform.
I have an excel file named "book" in format (.xlsx). I have two columns with ten rows each as shown below :
What I want to do ?
(i) Read the excel file in xlsx into matlab
(ii) For first 3 values in Column_1 , multiply with value 2 and Assign to a new array. Lets say array as "a"
(iii)For last 3 values in column_1 , multiply with value 3 and Assign to a new array. Lets say array as "b"
(iv) Concatenate the new arrays "a" and "b" into a single array . Lets say array as "c"
(v) Assign a new array for column_2 of the excel file, assign an array "d"
(vi) plot array "c" vs "d"
What I did ?
What I wish to do ?
How to implement a loop to automate this process instead of writing separate syntax as I have did above . How to get to the same result with a use of loop in matlab ?
Kindly cast your opinion to optimise the process.
Thanks from Basic Matlab Learner
At present, I am learning to work with matlab. I want to learn how to implement a basic loop for the following steps I perform.
I have an excel file named "book" in format (.xlsx). I have two columns with ten rows each as shown below :
CODE
serial value 1 0.15 2 0.20 3 0.52 4 0.24 5 0.05 6 -2.05
What I want to do ?
(i) Read the excel file in xlsx into matlab
(ii) For first 3 values in Column_1 , multiply with value 2 and Assign to a new array. Lets say array as "a"
(iii)For last 3 values in column_1 , multiply with value 3 and Assign to a new array. Lets say array as "b"
(iv) Concatenate the new arrays "a" and "b" into a single array . Lets say array as "c"
(v) Assign a new array for column_2 of the excel file, assign an array "d"
(vi) plot array "c" vs "d"
What I did ?
CODE -->
data=xlsread('book');
a=data(1:3,1)*2;
b=data(4:6,1)*3;
c=[a;b];
d=data(:,2);
plot(c,d) What I wish to do ?
How to implement a loop to automate this process instead of writing separate syntax as I have did above . How to get to the same result with a use of loop in matlab ?
Kindly cast your opinion to optimise the process.
Thanks from Basic Matlab Learner





RE: Help regarding Use of basic loop in matlab
Since, I work with large number of values (row wise) in Excel sheet in a single column , I want to multiply every 10 values in column1 with a factor , then next 10 values in column1 with an another factor And SO ON . I want to do this in a loop.
RE: Help regarding Use of basic loop in matlab
CODE --> Matlab