Making a 3D plot in a vectorized function

1 回表示 (過去 30 日間)
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013 年 2 月 9 日
I have a vectorized function which accepts an input vector such as:
y=myfun(x)
where
x=[x(1) x(2)]
and I want to assign vectors in x(1) and x(2) in order to make 3D plot. Do you know how can I implement this?

回答 (1 件)

the cyclist
the cyclist 2013 年 2 月 9 日
Here's one way, using a cell array to hold the two vectors:
>> c = cell(1,2);
>> x = 1:10;
>> y = 1:20;
>> c{1} = x;
>> c{2} = y;
>> myfun(c)
where the file myfun.m has
function myfun(x)
[xx,yy] = meshgrid(x{1},x{2});
zz = xx + yy.^2;
figure
mesh(xx,yy,zz)
end
  7 件のコメント
the cyclist
the cyclist 2013 年 2 月 10 日
Unfortunately, I do not have the symbolic toolbox. I suggest that you take this latest comment you just made, and create a brand-new question out of it. It seems much clearer now what you are trying to do. Probably you will find some help.
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013 年 2 月 10 日
Thank you very much for the effort. I will do that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by