Gistlib Logo

gistlib

write a function addsecondandthird that takes a vector as input and returns the sum of its second and third elements. assume the vector input will always have at least three elements in matlab

main.m
function sum = addsecondandthird(vec)
    sum = vec(2) + vec(3);
end
69 chars
4 lines

similar matlab code snippets

create a mat lab function that takes as input a number of sides and side length of polygon and outputs location of polygon vertices in matlab
create a function t=pe^rt. t is total amount, p is the principal loan, r is the loan amount, and t is time in matlab
create a function that accepts a vector input v and a vector input i and returns the value of v indexed by i. in matlab
create a function that accepts 2 scalar inputs (a and b) and returns a vector output numbers counting by 1 from a to b. in matlab
how to calculate the skewness of a vector in matlab
create a function that accepts a vector input and a scalar input and returns the value of the vector indexed by the scalar. in matlab
design the function function out = mse_loss(x, y) that computes the empirical mse loss of prediction x using the true labels y, both vectors of the same length. in matlab
how to calculate the minimum of a vector in matlab
how to calculate the product of a vector in matlab
how to calculate the maximum of a vector in matlab

related categories

`matlab
vector
function

gistlibby LogSnag