How to get output using a function with two parameters of different range

For instance, I have a function x = cb( a, b)
the paramter a ranges from 0 to 1 and b ranges from (2 to 20).
How do I perform a for loop to plot x for these parameters range.
Your help will be greatly appreciated
Best wishes

6 Kommentare

This will be a 3D plot, because you have two indices for the input and 1 value for the output. There are many different types of 3D plots. So how do you want the output to look like?
Yes thanks for responding. I will like a 3D line plot.
The ranges a and b will be on the y and x axis respectively, while the out put (x) will be on the z axis
Do you want to display the surface as points, surf, patch, bars, the z value encoded as color?
Yes thanks for responding, I will like to display the surface as points and the z value encoded as color.
Also I would like to display in the plot the optimal values for x function and the value of a and b that gives the optimal x values if possible

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Abhishek Gupta
Abhishek Gupta am 16 Apr. 2021
Bearbeitet: Abhishek Gupta am 16 Apr. 2021
Hi,
As per my understanding, you want to display a surface plot between a, b, and x. You can do the same as follows: -
a = linspace(0, 1, 10);
b = linspace(2, 20, 10);
[X,Y] = meshgrid(a,b);
Z = cb(X, Y);
surf(X,Y,Z);
For more information, check out the documentation link below: -

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020a

Gefragt:

am 13 Apr. 2021

Kommentiert:

am 3 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by