I need Correct Subplot for This Code

1 vue (au cours des 30 derniers jours)
arash Moha
arash Moha le 1 Mai 2021
Modifié(e) : arash Moha le 2 Mai 2021
Hi Everyone , I'm new to using MATLAB.
Please Help me , Thanks a lot.
This is my Homework Question :
The desired array is a subset of the number of data attributes (columns) in the CSV table file.
Note: In this exercise, two Nested FOR are used.
We want to have a subplot (for example 5 by 5) in which two attributes (columns) are displayed relative to each other.
The number of selected attributes is given as an array to the input function (for example as] [1 5 8 3] which means that we want to see the attributes mentioned in pairs in a 4 by 4 subplots.
Also for each case of Pairs of array elements plots we want to apply linear regression and then with the help of coefficients obtained from the function, polyfit draw a line graph on each plots.
Example of Correct Output Subplots
This Picture is The Example Of Correct Output Subplots For Array : [1 5 8 3]
This is my code but i have some problem , Based on this code, the output is not same as this picture ,i need correct subplot code :
Arrayinput = input ('Enter Array: ');
CASP = csvread('CASP.csv');
alength = length (Arrayinput);
for i=Arrayinput
for j=Arrayinput
i1=CASP(:,i);
j1=CASP(:,j);
%subplot(alength,alength,i); this is my problem , what is corrcet
%subplot for this Nested For Loop and array
plot(j1,i1,'.');
if (i==j)
title([num2str(i),'->',num2str(j),'y=x',' ','MSE = ']);
end
if (i~=j)
title([num2str(i),'->',num2str(j),' ','MSE = ']);
end
end
end

Réponse acceptée

Jan
Jan le 2 Mai 2021
counter = 0;
for i=Arrayinput
for j=Arrayinput
...
counter = counter + 1;
subplot(alength, alength, counter);
  1 commentaire
arash Moha
arash Moha le 2 Mai 2021
Modifié(e) : arash Moha le 2 Mai 2021
thanks a lot ,it is working. In this part of code, i need showing the column name in the title but it showed column number ,All of 10 columns name is (F1,F2,F3,F4,F5,F6,F7,F8,F9,RMSD) , what am i doing for this problem ?
if (i==j)
title([num2str(i),'->',num2str(j),'y=x',' ','MSE = ']);
end
if (i~=j)
title([num2str(i),'->',num2str(j),' ','MSE = ']);
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by