help with eval function - calculating multiple arrays at once
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Euan Muir
am 13 Mär. 2021
Beantwortet: Walter Roberson
am 13 Mär. 2021
Hi, I need to calculate a seperate array for 'speedMsAWP' for each the speedMS values 1 to 12. So one the code had finished running I would have 12 unique speedMsAWP arrays that were calculated with the speedMS arrays(1 to 12). I was recommened to use the eval function to do this. Any help appreciated.
The code below is what I have so far
speedMS1 = speedMS(1:744,:);
speedMS1 = speedMS1(:);
speedMS2 = speedMS(745:1416,:);
speedMS2 = speedMS2(:);
speedMS3 = speedMS(1417:2160,:);
speedMS3 = speedMS3(:);
speedMS4 = speedMS(2161:2880,:);
speedMS4 = speedMS4(:);
speedMS5 = speedMS(2881:3624,:);
speedMS5 = speedMS5(:);
speedMS6 = speedMS(3625:4344,:);
speedMS6 = speedMS6(:);
speedMS7 = speedMS(4345:5088,:);
speedMS7 = speedMS7(:);
speedMS8 = speedMS(5089:5832,:);
speedMS8 = speedMS8(:);
speedMS9 = speedMS(5833:6552,:);
speedMS9 = speedMS9(:);
speedMS10 = speedMS(6553:7296,:);
speedMS10 = speedMS10(:);
speedMS11 = speedMS(7297:8016,:);
speedMS11 = speedMS11(:);
speedMS12 = speedMS(8017:8760,:);
speedMS12 = speedMS12(:);
a = 0.11
speedMsAWP(1 to 12) = speedMS(1 to 12) *((30/31)^a);
Akzeptierte Antwort
Walter Roberson
am 13 Mär. 2021
bounds = [1 745 1417 2161 2881 3625 4345 5809 5833 6553 7297 8017 8761];
if size(speedMS,1) > bounds(end)
bounds(end+1) = size(speedMS,1)+1;
end
speedMSCells = mat2cell(spedMS, diff(bounds), size(speedMS,2));
speedMSCells = speedMSCells(1:12); %discard anything after 8760
c = (30/31).^0.11;
speedMSAWPcells = cellfun(@(C) C(:).*c, speedMSCells, 'uniform', 0);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!