Questions about vectors and matrices
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Geriffa
am 12 Mai 2018
Bearbeitet: Ameer Hamza
am 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?
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 12 Mai 2018
Bearbeitet: Ameer Hamza
am 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!