MATLAB: The plot is not showing

interpolationMATLABplot

Hello, I'm new to matlab. For a homework I need to plot a spline from two vectors.
file = fopen('data_xi.txt');
reel = fscanf(file, '%f', [14]);
fclose(file)
file = fopen('data_yi.txt');
imag = fscanf(file, '%f', [14]);
fclose(file)
xx = 0:.05:8;
yy = spline(reel,imag,xx);
figure(1)
plot(real,imag,'o',xx,yy);
xlabel('Voltage(mV)') ;
ylabel('Current(A)') ;
I'm not sure I understand how spline works, I just copied an example and tried to apply it to my case. When I run the code, the plot window opens but nothing shows up.
Thanks for any help

Best Answer

  • The following code works correctly on my system. This was a little type in your code
    file = fopen('data_xi.txt');
    reel = fscanf(file, '%f', [14]);
    fclose(file)
    file = fopen('data_yi.txt');
    imag = fscanf(file, '%f', [14]);
    fclose(file)
    xx = 0:.05:8;
    yy = spline(reel,imag,xx);
    figure(1)
    plot(reel,imag,'o',xx,yy);
    xlabel('Voltage(mV)') ;
    ylabel('Current(A)') ;
    The .txt files are also attached.