フィルターのクリア

Is it possible to use surf function calling parameters from a 4-D matrix?

5 ビュー (過去 30 日間)
bugatti79
bugatti79 2013 年 9 月 29 日
コメント済み: bugatti79 2013 年 10 月 1 日
I have an equation which is a fn of four variables. So i created a 4-D matrix to calculate an output, ie Output=f(a,b,c,d) inside a multi for loop of 4.
Now I wish to use the surf command to plot Output as fn of any above 2 variables.
It seems I can only plot a surface if the matrix is of the form Output=f(a,b,c), ie
surf(a,b,output(:,:,1,1)
It does not accept any other variation like
surf(a,b,output(1,:,:,1) etc
So am i restricted to Output=f(a,b,c) inside the for loop?
Thanks in advanced

採用された回答

Wayne King
Wayne King 2013 年 9 月 29 日
You can use squeeze() to do this
output = randn(20,20,20,20);
surf(squeeze(output(1,:,:,1)))
  2 件のコメント
bugatti79
bugatti79 2013 年 9 月 30 日
Works a treat, thank you Wayne
bugatti79
bugatti79 2013 年 10 月 1 日
編集済み: bugatti79 2013 年 10 月 1 日
Hi Wayne, I have come across some confusion when selecting parameters from the 4D matrix into the surf command.
Referring to my original message, say I want to issue the following
surf(c,d,squeeze(output(1,1:,:))).
Sometimes the squeeze(output) is a row vector instead of a column vector and it doesn't match with the inputs c,d. So I end up transposing the squeeze(output) and the result 'looks right' but I am doing it rather blindly. So the question I have is
1)If the inputs are column vectors then the output must also be a matching column vector and so I must transpose in order to achieve this?
2)Does the matching work in chronological order? ie,
surf(a,b, squeeze(output(:,:,1,1)
surf(b,c, squeeze(output(1,:,:,1)
surf(c,d, squeeze(output(1,1,:,:)
surf(a,d, squeeze(output(:,1,1,:) etc
Thanks in advanced.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by