Effacer les filtres
Effacer les filtres

Questions about vectors and matrices

1 vue (au cours des 30 derniers jours)
Geriffa
Geriffa le 12 Mai 2018
Modifié(e) : Ameer Hamza le 12 Mai 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?

Réponse acceptée

Ameer Hamza
Ameer Hamza le 12 Mai 2018
Modifié(e) : Ameer Hamza le 12 Mai 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.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by