# plot and surf 3D graph

조회 수: 4(최근 30일)
siew chin cheu 2011년 11월 9일
답변: VBBV 2021년 11월 29일
dear all, i am a new learner of matlab and was given a assignment to solve a matlab programming question. some errors occur and i unable to plot 3D graph. the error shown is as follow:
??? Error using ==> plot
Data may not have more than 2 dimensions
Error in ==> aaa at 28
subplot(2,2,1), plot(sseff);
the work that I did is as follow:
for Kp = 1:1:3
for tau = 1:1:3
for theta = 1:1:3
for lambda = 1:1:3
%Tuning the controller
Kc(Kp, tau, theta, lambda) = (2*tau+theta)/2*Kp*(lambda+theta);
taui(tau, theta)= tau+theta/2;
taud(tau, theta)= tau*theta/(2*tau+theta);
num = Kp;
den = [tau 1];
sp = 1;
[numCL,denCL]=cloop(Kc(Kp, tau, theta, lambda)*num*theta,den, -1);
t=0:0.01:5;
y = step(numCL, denCL,t);
sse = (sp - y);
ssef =sum(sse'*sse);
sseff(Kp, tau, theta, lambda) = ssef
end
end
end
end
subplot(2,2,1), plot(sseff);
title('Plot of SSE with multiple values of Tau')
ylabel('Sum of Square Error')
xlabel('Tdelay')
grid;
subplot(2,2,2), surf(sseff')
title('Plot of Sum of Square Error')
ylabel('Tau')
xlabel('Tdelay')
zlabel('Sum of Square Error')
subplot(2,2,3),plot(Kc)
title('Plot of Gain Kc')
xlabel('Tdelay')
ylabel('Sum of Square Error')
grid;
subplot(2,2,4),surf(Kc')
title('Plot of Kc with multiple values of Tau')
ylabel('Tau')
xlabel('Tdelay')
zlabel('Sum of Square Error')
so can anyone help me to find out what are the errors and the correct answers? thank you. My email address: siewchin0911@yahoo.com

댓글을 달려면 로그인하십시오.

### 답변(2개)

Fangjun Jiang 2011년 11월 9일
The error message says it all. Data used in plot() may not have more than 2 dimensions. Your data sseff seems to have a dimension of 4.
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

VBBV 2021년 11월 29일
for Kp = 1:1:3
for tau = 1:1:3
for theta = 1:1:3
for lambda = 1:1:3
%Tuning the controller
Kc(Kp, tau, theta, lambda) = (2*tau+theta)/2*Kp*(lambda+theta);
taui(tau, theta)= tau+theta/2;
taud(tau, theta)= tau*theta/(2*tau+theta);
num = Kp;
den = [tau 1];
sp = 1;
[numCL,denCL]=cloop(Kc(Kp, tau, theta, lambda)*num*theta,den, -1);
t=0:0.01:5;
y = step(numCL, denCL,t);
Sse = (sp - y); % change variable name convention
ssef =sum(Sse'*Sse); % use a variable with non-standard function,
sseff(Kp, tau, theta, lambda) = ssef;
end
end
end
end
subplot(2,2,1), plot(sseff(1,:,2,1));
title('Plot of SSE with multiple values of Tau')
ylabel('Sum of Square Error')
xlabel('Tdelay')
grid;
subplot(2,2,2),
skx(:,:) = sseff(1,:,2,:);
surf(skx)
title('Plot of Sum of Square Error')
ylabel('Tau')
xlabel('Lambda')
zlabel('Sum of Square Error')
subplot(2,2,3),plot(Kc(1,:,2,1))
title('Plot of Gain Kc')
xlabel('Tdelay')
ylabel('Sum of Square Error')
grid;
subplot(2,2,4), kkx(:,:) = Kc(1,:,2,:); surf(kkx)
title('Plot of Kc with multiple values of Tau')
ylabel('Tau')
xlabel('Lambda')
zlabel('Sum of Square Error')
Use the specific variable ,dimension range to plot your results. From the axis labeling variables, you can select which one to plot.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by