How to vary the interval of this matrix?
Show older comments
Thank you all for the reply. I already solved, in part, the problem I had, but now I have another. I have this line of code:
prueba=['MK_G', num2str(px(j,1)),'(4:6,4:6)'];
where 'MK_G', num2str (px (j, 1)) are N number of matrices that are already created. but I require, in some way, that the intervals of the matrix that I am evaluating (in this case 4: 6,4: 6) are in some way variable. I thank you for your collaboration with this new problem.
6 Comments
jonas
on 26 Jul 2018
What do you mean by variable? How do you want to set the interval?
Pedro Guevara
on 26 Jul 2018
Edited: Pedro Guevara
on 26 Jul 2018
Star Strider
on 26 Jul 2018
‘I already solved, in part, the problem I had, ...’
Please link to it to provide a context.
Pedro Guevara
on 26 Jul 2018
Steven Lord
on 26 Jul 2018
jonas
on 26 Jul 2018
Ugh.. Looks like he didn't pick up on the advice regarding dynamic variables.
Answers (1)
i is your variable, then
formatSpec = '(%d:%d,%d:%d)';
str = sprintf(formatSpec,i,i+2,i,i+2)
prueba=['MK_G', num2str(px(j,1)),str];
You want the length of the interval to be variable as well? Just change the 2 to a variable.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!