Questions about vectors and matrices

1 次查看(过去 30 天)
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?

采纳的回答

Ameer Hamza
Ameer Hamza 2018-5-12
编辑:Ameer Hamza 2018-5-12
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by