MATLAB Answers

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

1 view (last 30 days)
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

  0 Comments

Sign in to comment.

Accepted Answer

Erivelton Gualter
Erivelton Gualter on 20 Nov 2019
Edited: Erivelton Gualter on 20 Nov 2019
% Given A as:
A = 1:194;
% We can simply solve the following:
B = 2+2./A;

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2018a