Function returns scalar independent of input, but I need a matrix output
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
KSSV
on 30 Mar 2022
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))
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!