Writing mathematical function in code

조회 수: 4 (최근 30일)
sissy sissy
sissy sissy 2019년 11월 28일
댓글: Walter Roberson 2019년 11월 28일
Hi! Can somebody help me how to write the following function in Matlab?
(1/2*N)*||x||^2 + (1/2*N) Σ max(0.1-(v(i)*(x0+u(i)*x))^2) with i from 1 up to N
I thought to start from the max but i only know how to calculate the max of a matrix. Should i put the prices of (0.1-(v(i)*(x0+u(i)*x))^2) in a matrix and then find the max?
Thank you.
  댓글 수: 3
sissy sissy
sissy sissy 2019년 11월 28일
Thank you for the answer! I know that x belongs to R^n and that x0 belongs to R.
Walter Roberson
Walter Roberson 2019년 11월 28일
max(0.1-(v(:).*(x0+u(:).*x(:).')).^2, 2)

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by