Borrar filtros
Borrar filtros

Questions about vectors and matrices

1 visualización (últimos 30 días)
Geriffa
Geriffa el 12 de Mayo de 2018
Editada: Ameer Hamza el 12 de Mayo de 2018
Hi,
So i've saved a bunch of values read from a URL text file. I saved these values in variables called XCX1, XCX2 and XCX3. These register as 168x1 double. Now, im guessing these counts as vectors and I now want to put these together into a 168 row by 3 column matrix.
pleb=1;
for j=pleb:1:3
go=true;
while go==true
prompt = 'Mata in vilken månad (månadens siffra) du vill kolla: ';
M_Start = input(prompt);
prompt = 'Mata in startdag: ';
S_dag = input(prompt);
prompt = 'Mata in slutdag: ';
E_dag = input(prompt);
if E_dag - S_dag > 6
fprintf(2,'\nlorem ipsum\n');
go=true;
elseif E_dag - S_dag <= 6
go=false;
end
end
stuff = ['The URL'];
timgrejer = urlread(stuff);
timgrejer_matris = str2num(timgrejer);
Q_timgrejer_matris = timgrejer_matris(:,5);
mangd = numel(Q_timgrejer_matris);
if pleb == 1
XCX1 = Q_timgrejer_matris;
elseif pleb == 2
XCX2 = Q_timgrejer_matris;
else
XCX3 = Q_timgrejer_matris;
end
pleb=pleb+1;
end
Is this possible or am I completely lost?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 12 de Mayo de 2018
Editada: Ameer Hamza el 12 de Mayo de 2018
Before for loop
XCX = zeros(3, 168); % pre-allocate an array, it increase speed
Instead of if else structure use
XCX(pleb, :) = Q_timgrejer_matris;
It will assign values to rows of XCX according to the value of pleb.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by