Take values from an matrix automatically.

1 visualizzazione (ultimi 30 giorni)
Ricardo Gutierrez
Ricardo Gutierrez il 10 Set 2019
Hi !!!, Good morning.
I would like to help me in the following:
I have an 18 X 3 matriaz, which can also be 18 X n
Each element of a line is a variable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; clear; close all; format short
Prog=[1.19 1.89 2.74 3.53 4.43 1.76 0.22 4.20 2.39 3.97 3.24 4.43 0.96 6.41 2.00 7.07 3.34 6.77
0.56 1.41 2.27 3.23 4.18 1.36 0.96 4.05 1.64 3.66 3.61 3.67 0.53 7.02 2.02 6.30 3.77 6.92
1.13 2.16 2.73 3.87 5.08 1.49 0.46 3.80 1.65 4.13 3.62 4.09 0.69 6.86 2.14 6.30 3.31 7.03 ];
% To get each of the elements in a variable I do the following for the first line.
dx1=Prog(1,1);
dy1=Prog(1,2);
dx2=Prog(1,3);
dy12=Prog(1,4);
dx3=Prog(1,5);
dy13=Prog(1,6);
dx12=Prog(1,7);
dy2=Prog(1,7);
dx21=Prog(1,7);
dy21=Prog(1,10);
dx31=Prog(1,11);
dy22=Prog(1,12);
dx13=Prog(1,13);
dy3=Prog(1,14);
dx22=Prog(1,15);
dy31=Prog(1,16);
dx32=Prog(1,17);
dy32=Prog(1,18);
% With this I have each of the values of the first line.
% How do I automatically get the code to take the values of the following lines?
  5 Commenti
Walter Roberson
Walter Roberson il 10 Set 2019
If you need to take a copy of the current values to use in calculations while you change the array, then you can
saved_row = Prog(i,:);
and then saved_row(6) would be dy13 and so on without having to write each value to a variable individually.

Accedi per commentare.

Risposte (1)

Fabio Freschi
Fabio Freschi il 10 Set 2019
Prog_old = Prog;
% modify Prog as desired
Prog = Prog*2; % dummy operation
% reload the old version
Prog = Prog_old;

Prodotti


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by