error in for loop

1 Input: Dataset with i continuous attribute, M examples and S target classes;
2 Begin
3 For each continuous attribute Ai
4 Find the maximum dn and the minimum d0 values of Ai;
5 Form a set of all distinct values of A in ascending order;
6 Initialize all possible interval boundaries B with the minimum and maximum
7 Calculate the midpoints of all the adjacent pairs in the set;
8 Set the initial discretization scheme as D: {[d0,dn]}and Globalcacc = 0;
9 Initialize k = 1;
10 For each inner boundary B which is not already in scheme D,
11 Add it into D;
12 Calculate the corresponding cacc value;
13 Pick up the scheme D’ with the highest cacc value;
14 If cacc > Globalcacc or k < S then
15 Replace D with D’;
16 Globalcacc = cacc;
17 k = k + 1;
18 Goto Line 10;
18 Else
19 D= D;
20 End If
21 Output the Discretization scheme D’ with k intervals for continuous attribute Ai;
22 End
i have completed till step 8
i am struck in for loop can u tell how to process please
B is a matrix
for calculating cacc i have posted in my previous post
please help

8 个评论

show some code to get help.
clc
clear all
OriginalData1=xlsread('dataset.xls','A1:F50');
[r c]=size(OriginalData1);
k=zeros(r,1);
OriginalData=[OriginalData1 k];
OriginalData=sort( OriginalData)
[r c]=size(OriginalData)
F=OriginalData
F1=F(:,1);
F2=F(:,2);
F3=F(:,3);
F4=F(:,4);
F5=F(:,5);
F6=F(:,6);
F_mid1 = conv(F1, [0.5 0.5], 'valid')
K=[F_mid1(1:end-1)' F_mid1(2:end)']'
[r c]=size(K)
L=r/2
J=reshape(K,L,[])
F_mid2 = conv(F2, [0.5 0.5], 'valid');
K2=[F_mid2(1:end-1)' F_mid2(2:end)']'
[r c]=size(K2)
L2=r/2
J2=reshape(K2,L2,[])
F_mid3 = conv(F3, [0.5 0.5], 'valid')
K3=[F_mid3(1:end-1)' F_mid3(2:end)']'
[r c]=size(K3)
L3=r/2
J3=reshape(K3,L3,[])
F_mid4 = conv(F2, [0.5 0.5], 'valid');
K4=[F_mid4(1:end-1)' F_mid4(2:end)']'
[r c]=size(K4)
L4=r/2
J4=reshape(K4,L4,[])
F_mid5 = conv(F5, [0.5 0.5], 'valid')
K5=[F_mid5(1:end-1)' F_mid5(2:end)']'
[r c]=size(K5)
L5=r/2
J5=reshape(K5,L5,[])
F_mid6 = conv(F6, [0.5 0.5], 'valid');
K6=[F_mid6(1:end-1)' F_mid6(2:end)']'
[r c]=size(K6)
L6=r/2
J6=reshape(K6,L6,[])
final=[J J2 J3 J4 J5 J6]
it would have been better to edit your question (and format the code) - also remember that we do not have (or want access) to your spreadsheet. You have still omitted the error message. I personally wont read all that code as I do not know your data - you need to simplify your problem so that it can be repeated in a few lines - doing that you will either solve it yourself or you will be more likely to get help!
B=[F(1:end-1)' F(2:end)']
Nor will we go to his separate post to figure out how he got cacc. That's asking a bit much when I'm sure this can be solved with standard debugging techniques, and who better to do that?
ok robert can u atleast tell how to calcualate cacc plz in my previous post
@Kash: It would be helpful, if you post a link to the "previous" post.
http://www.mathworks.in/matlabcentral/answers/25635-error-in-performing-summation

回答(1 个)

Doing things like:
F=OriginalData
F1=F(:,1);
F2=F(:,2);
F3=F(:,3);
F4=F(:,4);
F5=F(:,5);
F6=F(:,6);
is really ugly and rarely useful in MATLAB. I would suggest reading the getting start section of the manual ( http://www.mathworks.co.uk/help/techdoc/learn_matlab/bqr_2pl.html ) and the FAQ ( http://matlab.wikia.com/wiki/FAQ ). This will be more beneficial to you in the long run.
You should also search this site for the reasons not to use
clear all
at the beginning of your code.
and href=""<http://www.mathworks.co.uk/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup</a>>

3 个评论

Thank u image analyst can u please tell how to assign values as u said it is ugly way to do it ....and is it possible for u to code for me from my 9th line...can u atleast kelp for calculating cacc
I am not IA. I would say the original F is an elegant way to present F instead of F1, F2, ... F6. My guess is I could code for you line 9 and help with cacc, but I am not going to. Spend a little time reading and working through the documentation and FAQs, and I bet this will all become much easier.
Daniel i tried a lot only ten i seek help from others ,,,,i get only one cacc value for a loop where i should get many values ....this is my project thats the reason posting many question , i seek guide from u in my first project...please guide

此问题已关闭。

标签

提问:

2012-1-9

关闭:

2021-8-20

Community Treasure Hunt

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

Start Hunting!

Translated by