Shifting cells to the right in the header of array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
I have a problem with shifting the cells of the header in my 46x19 array with strings. The data in the array is correct, except for the first row which requires a shift to the right. I want to correct the array such that the 5th cell receives the information of the 4th cell, the 6th of the 5th and onwards until the last column number.
To solve this I have tried to create a for-loop that iterates over the column numbers, as can be seen in the code below. However, it does not change the values as I expect it to and I could not find a working solution on the internet. Can anyone help me out? Thanks!
[Rownr,Colnr] = size(gdp);
for 4:Colnr
gdp{} = gdp{1,Colnr+1};
end
0 Kommentare
Antworten (1)
Walter Roberson
am 6 Nov. 2019
gdp(1,5:end) = gdp(1,4:end-1);
No loop needed. Note that the content of columns 1, 2, 3, and 4 of the row will stay the same as they were.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!