How can I plot the derived function of cubic spline interpolation?

조회 수: 1 (최근 30일)
OK
OK 2017년 1월 31일
댓글: OK 2017년 1월 31일
Hello, I want to ask how I can plot the derived function of cubic spline interpolation? I show how I did it in my code. The error was:
*Error using plot *Invalid second data argument *Error in function_MTU4000_Real (line 90) *plot1=plot(x1,Speed1,'b');
%calculation of lifting of intake valve (approximation spline function)
x1=0.0:0.1:202.1;
y1=xlsread('Steuerzeiten_Schrittweite_MTU4000.xlsx',1,'D2:D2023');
Lifting1=spline(x1,y1);
x2=202.1:0.1:701.9;
Lifting2=0*x2;
x3=702.0:0.1:720.0;
y3=xlsread('Steuerzeiten_Schrittweite_MTU4000.xlsx',1,'D7022:D7202');
Lifting3=spline(x3,y3);
%calculation and plot of speed intake
figure(2);hold on; grid on;
Speed1=fnder(Lifting1);
plot1=plot(x1,Speed1,'b');
Speed2=Lifting2;
plot2=plot(x2,Speed2,'b');
Speed3=fnder(Lifting3);
plot3=plot(x3,Speed3,'b');
hold off
legend([plot1,plot2,plot3],'Intake')
set(gca,'XTickLabel',{'OT','90','UT','270','ZOT','450','UT','630','OT'});
title('Intake Valve Speed')
xlabel('Crank Angle [°]')
ylabel('Speed [m/°]')
  댓글 수: 2
KSSV
KSSV 2017년 1월 31일
Try to print the values of Speed1....does it have any numbers? We cannot check the code unless the xlsx file we have in hand.
OK
OK 2017년 1월 31일
Thank you very much for your answer! Ok, i attached the file as text, because i can't attach excel, but you can bring these values to a excel file and rename it the same. Besides if i write the code below, i get 'NaN' in the text file 'Speed1.txt'. So i think that something is wrong with Speed1. I hope you can help me to fix it.
%writing Speed1 to Speed1 text file
fileID=fopen('Speed1.txt','w');
formatSpec='%d\r\n';
Sp1=str2double(Speed1);
table=[Sp1]';
fprintf(fileID,formatSpec,table);
fclose(fileID);

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by