Why my plot is not showing?

2 vues (au cours des 30 derniers jours)
Fabricio Macias
Fabricio Macias le 29 Oct 2020
Commenté : Ameer Hamza le 29 Oct 2020
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
  1 commentaire
Fabricio Macias
Fabricio Macias le 29 Oct 2020
The data_xi has this values :
0.00000000
7.00000003E-02
0.730000019
1.42999995
3.41000009
6.01000023
7.32000017
7.59000015
7.67999983
7.76999998
7.80999994
7.88000011
7.90999985
7.92000008
And data_yi:
745.000000
744.000000
736.000000
729.000000
696.000000
615.000000
460.000000
331.000000
258.000000
187.000000
151.000000
98.5999985
67.5999985
46.4000015

Connectez-vous pour commenter.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 29 Oct 2020
Modifié(e) : Ameer Hamza le 29 Oct 2020
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.
  3 commentaires
Fabricio Macias
Fabricio Macias le 29 Oct 2020
I found the error, I wrote real instead of reel. Thank you again
Ameer Hamza
Ameer Hamza le 29 Oct 2020
Yes, reel was the type.
I am glad to be of help!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by