フィルターのクリア

Questions about vectors and matrices

1 回表示 (過去 30 日間)
Geriffa
Geriffa 2018 年 5 月 12 日
編集済み: Ameer Hamza 2018 年 5 月 12 日
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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by