Function returns scalar independent of input, but I need a matrix output
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
KSSV
am 30 Mär. 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))
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!