Running a calculation for an entire array and putting the results into a new array

조회 수: 51 (최근 30일)
Hello
I am trying to write code to run a calculation using the values in an array and storing them in a new array.
For example:
I have the array A, that has 194 values.
I want to use a calculation like: 2+2/n = c, with n being the number in the array and to store the answer, c, in array B.
I code use some help on the code, I don't know if it needs a for loop.
Thanks

채택된 답변

Erivelton Gualter
Erivelton Gualter 2019년 11월 20일
편집: Erivelton Gualter 2019년 11월 20일
% Given A as:
A = 1:194;
% We can simply solve the following:
B = 2+2./A;
  댓글 수: 2
Paul Torres
Paul Torres 2019년 11월 20일
Of course its this simple and I spent too much time on it. Thank you
Owen Brady
Owen Brady 2023년 4월 21일
How would I do an equation where the array is angles and must be in a cos and sin function?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by