Defining values into zeros matrix

How can i define all s4 values in a FIRSTSPACE?
LOWERLIMIT = 1 ;
UPPERLIMIT = 360 ;
FIRSTSPACE=zeros(LOWERLIMIT,UPPERLIMIT);
for q=(0:1:360)
s4=[(0.096.*cos(q))-(0.168.*sin(q))]
end

 采纳的回答

Hi,
You can directly execute
q= 0:1:360;
s4=[(0.096.*cos(q))-(0.168.*sin(q))]
Regards,
Sriram

3 个评论

s4 variable is of length 361, since the for loop starts from 0.
To only get the values from 1 to 360, use
FIRSTSPACE = s4(1:360); % Or FIRSTSPACE = s4(LOWERLIMIT:UPPERLIMIT);
Hope this helps.
@Sriram Tadavarty Thanks for your help, how can i write it in for loop for q=0:1:360
Using for loop is not apt here.
But, just in-case you only need it as such. Here is it:
LOWERLIMIT = 1 ;
UPPERLIMIT = 361 ;
FIRSTSPACE=zeros(LOWERLIMIT,UPPERLIMIT);
for q=(0:1:360)
FIRSTSPACE(q+1) = [(0.096.*cos(q))-(0.168.*sin(q))];
end
Regards,
Sriram

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File 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