how to choose k values

10 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2017-2-24
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 个评论
Nikolas Spiliopoulos
the new question is a different one,
thanks a lot
you are very helpful!
sorry for being a pain..I just started using matlab!
I am learning a lot from you
thanks!
Star Strider
Star Strider 2017-2-25
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.
Learning MATLAB will be much easier if you use the online tutorials. Begin with Getting Started.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by