How to create a contourf plot form a structure with 16 fields?

조회 수: 1 (최근 30일)
Carolin Widmann
Carolin Widmann 2020년 8월 29일
답변: Prudhvi Peddagoni 2020년 9월 1일
Hi everyone,
I have a structure with 16 fields for x,y, and u.
I want to create one contourf plot for the whole structure. How can I do this?
files = dir('Desktop\Daten\*.mat');
level2 = load([files.folder '/' files.name]);
for i = 1:16
x= level2.data(i).x;
y= level2.data(i).y;
u= level2.data(i).u;
Werte= struct('x',x,'y',y,'u',u);
figure;
hold on;
grid on;
[C,h] = contourf(Werte.x,Werte.y,Werte.u);
end
When I do it like this I get 16 different plots with different x-axes.
But I want a superposition.

답변 (1개)

Prudhvi Peddagoni
Prudhvi Peddagoni 2020년 9월 1일
Hi Carolin Widmann,
It seems that you are creating new figure for every iteration by calling figure function. Call this function before entering for loop so that only one figure is created and the hold on function will make sure that each new plot is added to the same figure.
Hope this helps.

Community Treasure Hunt

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

Start Hunting!