how to choose k values
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nikolas Spiliopoulos
am 24 Feb. 2017
Kommentiert: Star Strider
am 25 Feb. 2017
hi all,
I have an array of 365 values and I do some calculations with an index for k=1:365
However, I need to do some different calculations for some k (let's say k=7, k=9,k=11, k=12)
how can I select only these?
I imagine is something like that: for k=1:365
if k=7.....
else...
thanks
0 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Feb. 2017
It is easiest to address them directly:
v = randn(1,365); % Create Data
k = 1:365; % Index Vector
select_k = [7 9 11 12]; % Select ‘k’ Values
select_v = v(select_k); % Select ‘v’ Values
10 Kommentare
Star Strider
am 25 Feb. 2017
My pleasure.
You are not a pain. If you have previous programming experience, learning MATLAB will be relatively easy, once you get used to the conventions and programming environment. If you have no programming experience, learning any programming language for the first time will be a challenge.
Weitere Antworten (0)
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!