actually i am trying to do some binning in matlab .i am newbie in matlab so i dont know how to remove the error i have tried to sort out the problem but could not worked out. showing a error- SUBSCRIPT INDICES MUST EITHER BE REAL POSITIVE INTEGERS OR LOGICALS.
% code
endpoints=50; %separation btw points
bin=5
L=size(E)
minE=min(E)
maxE=max(E)
counter=0
for i=0:points:L
E(counter)=mean(E(i:i+bin));
if i+bin>L
break
end
dN=sum(n(i:i+bin));
dE=E(i+bin)-E(i)
if dE==0
dE=epsi
end
dn_o_dE(counter)=dN/dE
counter=counter+1
end

2 commentaires

Adam
Adam le 19 Mai 2016
There's no need to shout!
Pallavi
Pallavi le 8 Nov 2024

// Parameters ratchet_radius = 30; // Radius of the ratchet wheel ratchet_thickness = 5; // Thickness of the ratchet wheel pawl_length = 20; // Length of the pawl pawl_width = 4; // Width of the pawl pawl_thickness = 2; // Thickness of the pawl tooth_height = 5; // Height of each tooth on the ratchet tooth_width = 5; // Width of each tooth

// Ratchet Wheel module ratchet_wheel() { difference() { // Main wheel cylinder(r = ratchet_radius, h = ratchet_thickness);

        // Teeth
        for (i = [0:11]) {
            rotate([0, 0, i * 30]) {
                translate([ratchet_radius, 0, 0])
                    cube([tooth_width, tooth_height, ratchet_thickness]);
            }
        }
    }
}

// Pawl module pawl() { rotate([90, 0, 0]) // Align pawl horizontally translate([5, 0, 0]) // Adjust pawl position cube([pawl_length, pawl_width, pawl_thickness]); }

// Cam Profile (Simple representation as a ring) module cam_profile() { difference() { // Cam body cylinder(r1 = ratchet_radius, r2 = ratchet_radius + 5, h = 5);

        // Creating the profile that moves the pawl (simple cam for demonstration)
        translate([0, 0, -0.5]) {
            cylinder(r = ratchet_radius + 3, h = 6);
        }
    }
}

// Assemble the mechanism module ratchet_pawl_mechanism() { ratchet_wheel(); pawl(); cam_profile(); }

// Display the full mechanism ratchet_pawl_mechanism();

Connectez-vous pour commenter.

 Réponse acceptée

John D'Errico
John D'Errico le 19 Mai 2016
Modifié(e) : John D'Errico le 19 Mai 2016

0 votes

MATLAB does NOT use zero based indexing.
However, in several places, you index with a variable that takes on that value. For example, in this line alone:
E(counter)=mean(E(i:i+bin));
both the counter variable and i start out as 0.
READ THE ERROR MESSAGE!
"SUBSCRIPT INDICES MUST EITHER BE REAL POSITIVE INTEGERS OR LOGICALS."
When last I checked, 0 was not a positive integer. Don't do that, and your problems will go away.

1 commentaire

i have changed counter=0 to 1, but what should i do with for loop case when i dont know the initial points how can i directly change it to 1 from zero,its a user interface so it will change again and again
% code
for i=0:points:L

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by