for i=1:10 power=(i*i) end; this is my programme and ,now i want to calculate all the values of power.

댓글 수: 1

mahesh chathuranga
mahesh chathuranga 2013년 9월 10일
thak you very much.i'm very new for MATLAB

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2013년 9월 7일

2 개 추천

Do you have a question, other than "How do I format my code?" which is answered by this. Might it be "How do I get power to be an array?" If so, just make * a .* and drop the "for" and "end".
k = 1 : 10; % No "for" needed since it's now vectorized.
power = k .* k % or can use power = k .^2

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by