Function returns scalar independent of input, but I need a matrix output
조회 수: 1 (최근 30일)
이전 댓글 표시
I have function handle f:
f = @(x)4.3206303272e-05.*x(1).^2+2.39837699915e-05.*x(2).^2
Where x is a
vector. I want to plot the mesh of this function, but each input returns a scalar. For example:

f([1 0]) = 4.3206e-05
f([1:4 5:7]) = 1.3914e-04
f3([rand(3) rand(3)]) = 5.3729e-06
How come, and how can I change this?
I came to a function handle because of this: Link
댓글 수: 2
답변 (1개)
KSSV
2022년 3월 30일
clc; clear all ;
f = @(x1, x2)4.3206303272e-05.*x1.^2+2.39837699915e-05.*x2.^2 ;
f(1,0)
f([1:4]', [5:8]')
f(rand(3,1),rand(3,1))
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!