Colon operands must be real scalars
I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100);I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100); I tested the following code:
x = rand(1,3);
x([1,2]:[1,2])
In R2024a it gives a warning but it is ok in R2023b! Some existing code that I use relies on this feature. Any reason why it will become an error in the future?
For a better example of how using non-scalar colon operands may be useful:
clear,clc
Params.agejshifter.College=21;
Params.J.College=100-Params.agejshifter.College;
Params.agej.College=1:1:Params.J.College;
Params.J.College=100-Params.agejshifter.College; % Age ends at 100
dj_temp=interp1([0,30,60,65,70,100],[0.00587,0.00116,0.01086,0.01753,0.02785,0.39134],0:1:100,’linear’);
Params.sj.College=1-dj_temp((Params.agej.College+Params.agejshifter.College):100); colon, array indexing MATLAB Answers — New Questions