*Check this below code to generate a surface plot. It's showing an error.*
t_res = 0.2;
c_angle = 360/30;
iact = 0.1;
V = 12;
p = 1;
%%fprintf('Slno\t\t Time\t\t Angle(degree)\t\t Current\t\t delta_i\t\t Torque\t\t Fluxlinkage\t\t L_obt\n');
for p=1:5,
Time = p*t_res;
Angle = Time*c_angle/2;
if (p == 1)
delt_i = 0;
else
delt_i = 0.5* t_res* V /L_obt;
end
iact = iact+delt_i;
[~, ~, raw] = xlsread('F:\Pradeep\Matlab\data1.xlsx','Sheet3','A2:D11');
data = reshape([raw{:}],size(raw));
Current = data(:,1);
Angle1 = data(:,2);
Torque = data(:,3);
Fluxlinkage = data(:,4);
F = scatteredInterpolant(Current,Angle1,Fluxlinkage);
Fluxlinkage = F(iact,Angle);
L_obt = Fluxlinkage/iact;
F = scatteredInterpolant(Current,Angle1,Torque);
Torque = F(iact,Angle);
Table = [p' Time' Angle' iact' delt_i' abs(Torque)' Fluxlinkage' L_obt'];
fprintf('%d\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\n', Table');
end
p=p+1;
plot3(Time,iact,Torque);

댓글 수: 6

Rik
Rik 2017년 10월 24일
You attached a .txt, while your code loads .xlsx. Also, your steps to convert a cell to a matrix are a bit odd. Why not use the first output from xlsread, or even cell2mat? And if you want to create a surface plot, why use plot3 instead of surf?
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
Copy the .txt file in .xlsx format and check it. I couldn't upload .xlsx file so i've copied it to .txt file. I want to make with respect to time.
KSSV
KSSV 2017년 10월 25일
It is your duty to copy and attach.....here no one does what you demand...be careful while commenting or asking a question.
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
편집: Pradeepta Sahu 2017년 10월 25일
The file format of .xlsx is unsupoorted to attach.
KSSV
KSSV 2017년 10월 25일
There are ways to attach....can be zipped and attached.
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
Thanks. attached.

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

답변 (1개)

KSSV
KSSV 2017년 10월 25일

0 개 추천

data = [0.1 1 2.3 0.5
3 2 3.4 0.86
4 3 2.7 0.8739
5 4 4.5 0.4382
6 5 3.4 0.8234
7 6 5.5 0.53823
8 7 4.3 0.7482
9 8 4 0.3439
10 9 3.5 0.2593
11 10 2.4 0.2432];
c = data(:,1) ;
theta = data(:,2) ;
tor = data(:,3) ;
flux = data(:,4) ;
[C,T] = meshgrid(c,theta) ;
F = scatteredInterpolant(c,theta,tor) ;
Tor = F(C,T) ;
figure
surf(C,T,Tor) ;
title('surface plot of Torque')

댓글 수: 10

Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
편집: Pradeepta Sahu 2017년 10월 25일
Where is the time variable? Check my code properly. It involves time variable and I 'm trying to plot a surface in time, current and torque.
KSSV
KSSV 2017년 10월 25일
Check my code properly.: Don't be demanding...remember you are asking for help here.
Where is time? First tell me where is time in your attached text file. YOu have attahced .txt file and loading .xlsx file in code...
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
I'm not demanding. I'm asking for help only. However, I've removed the .txt file as i thought it'll be helpful for understanding the code. I was trying to plot a surface from the experimental data of 4 variables(current, angle, torque, fluxlinkage). And the plot is of Time (can be calculated as in code), current and torque.
KSSV
KSSV 2017년 10월 25일
t_res = 0.2;
c_angle = 360/30;
iact = 0.1;
V = 12;
p = 1;
%%fprintf('Slno\t\t Time\t\t Angle(degree)\t\t Current\t\t delta_i\t\t Torque\t\t Fluxlinkage\t\t L_obt\n');
x = zeros(5,1) ;
y = zeros(5,1) ;
z = zeros(5,1) ;
for p=1:5,
Time = p*t_res;
Angle = Time*c_angle/2;
if (p == 1)
delt_i = 0;
else
delt_i = 0.5* t_res* V /L_obt;
end
iact = iact+delt_i;
[~, ~, raw] = xlsread('data1.xlsx','Sheet3','A2:D11');
data = reshape([raw{:}],size(raw));
Current = data(:,1);
Angle1 = data(:,2);
Torque = data(:,3);
Fluxlinkage = data(:,4);
F = scatteredInterpolant(Current,Angle1,Fluxlinkage);
Fluxlinkage = F(iact,Angle);
L_obt = Fluxlinkage/iact;
F = scatteredInterpolant(Current,Angle1,Torque);
Torque = F(iact,Angle);
Table = [p' Time' Angle' iact' delt_i' abs(Torque)' Fluxlinkage' L_obt'];
fprintf('%d\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\n', Table');
x(p) = Time ;
y(p) = iact ;
z(p) = Torque ;
end
plot3(x,y,z);
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 25일
Thanks. But, if i'm trying to plot surface using function surf it's showing an error.
KSSV
KSSV 2017년 10월 25일
For surface....you should refer to my first code......try to involve time in that.
Pradeepta Sahu
Pradeepta Sahu 2017년 10월 27일
편집: Pradeepta Sahu 2017년 10월 27일
I'm getting an error as "Z must be a matrix, not a scalar or vector".
Pradeepta Sahu
Pradeepta Sahu 2017년 11월 3일
Can you help me to solve this problem?
KSSV
KSSV 2017년 11월 3일
Copy your whole code here....
Pradeepta Sahu
Pradeepta Sahu 2017년 11월 3일
편집: Pradeepta Sahu 2017년 11월 3일
t_res = 0.2;
c_angle = 360/30;
iact = 0.1;
V = 12;
p = 1;
%%fprintf('Slno\t\t Time\t\t Angle(degree)\t\t Current\t\t delta_i\t\t Torque\t\t Fluxlinkage\t\t L_obt\n');
x = zeros(5,1) ;
y = zeros(5,1) ;
z = zeros(5,1) ;
[~, ~, raw] = xlsread('data1.xlsx','Sheet3','A2:D11');
data = reshape([raw{:}],size(raw));
Current = data(:,1);
Angle1 = data(:,2);
Torque = data(:,3);
Fluxlinkage = data(:,4);
for p=1:5,
Time = p*t_res;
Angle = Time*c_angle/2;
if (p == 1)
delt_i = 0;
else
delt_i = 0.5* t_res* V /L_obt;
end
iact = iact+delt_i;
F = scatteredInterpolant(Current,Angle1,Fluxlinkage);
Fluxlinkage = F(iact,Angle);
L_obt = Fluxlinkage/iact;
F = scatteredInterpolant(Current,Angle1,Torque);
Torque = F(iact,Angle);
Table = [p' Time' Angle' iact' delt_i' abs(Torque)' Fluxlinkage' L_obt'];
fprintf('%d\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\t\t %f\n', Table');
x(p) = Time ;
y(p) = iact ;
z(p) = Torque ;
[C,T,Tor] = meshgrid(iact,Angle, Torque) ;
F = scatteredInterpolant(Current,Angle1,Torque) ;
Tor = F(C,T) ;
end
figure
surf(C,T,Tor) ;

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

카테고리

태그

질문:

2017년 10월 23일

편집:

2017년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by