Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
what do i have to do here to get the vectors the same size without vompromising the graphs integrity?

Subject: what do i have to do here to get the vectors the same size without vompromising the graphs integrity?

From: raaj kumar

Date: 17 Nov, 2010 02:14:04

Message: 1 of 3

hey guys im trying to draw a graph and its not plotting because the vectors are not equal, how do i make them equal without chaning the integrity of the graph, so it still represents the same thing??

%generating function for cumulative particle size distribution with d50 =
%5, w= 0.45, these are boltzmann parameters

d50 = 5; w=0.45;
d=0:0.01:10;
d500=5.5;
w0=0.45; %initial width distribution
%particle size dist model
kd =700;

n =5;
p =650;

% the basis for a new average and particle distribution is defined by d50s
% aka d50star

if p >115 && n>0;
        d50s =exp(-kd*(n^0.4)*(p-115));
    else d50s=0;
end

% size distribution width defined by w

if d50s>0.33;
w= ( 1 + 2.33*d50s)*w0;
else
    w =(3.4-(5.5 * d50s))*w0;
end;

% mean size
d50 = (1-d50s) * d500;
 
%plotting the graph
d50 = (1-d50s)*d500;
for i=1:100
    d(i)=0.1*(i-1);
    F(i)=1-(1./(1+exp((d(i)-d50)/w)));
end

Subject: what do i have to do here to get the vectors the same size without vompromising the graphs integrity?

From: Roger Stafford

Date: 17 Nov, 2010 02:38:03

Message: 2 of 3

"raaj kumar" <tambalan30@yahoo.co.uk> wrote in message <ibvdpc$lns$1@fred.mathworks.com>...
> hey guys im trying to draw a graph and its not plotting because the vectors are not equal, how do i make them equal without chaning the integrity of the graph, so it still represents the same thing??
> .......
> d=0:0.01:10;
> ........
> for i=1:100
> d(i)=0.1*(i-1);
> F(i)=1-(1./(1+exp((d(i)-d50)/w)));
> end
- - - - - - - - - - - -
  Earlier in your code you wrote d=0:0.01:10; which places 1001 entries into vector d. In the subsequent for-loop you have only given F a hundred elements. If that is the extent of vector F, they would of course be of different sizes. How is 'plot' supposed to know what you want? You must always give it vectors with like numbers of elements if it is to know what pairs to plot.

Roger Stafford

Subject: what do i have to do here to get the vectors the same size without vompromising the graphs integrity?

From: raaj kumar

Date: 17 Nov, 2010 03:01:04

Message: 3 of 3

I have changed the d value to:

d = 0.1:0.1:10

i get a cumulative s shaped graph, is this the correct graph i should get?

I ask this because the previous sheet of just:

function [d]= psdd50 (d, c)

% calc cumulative particle size dist
% use while loop
d50 =5;
w=0.45;

%give the interval
interval = 0.01;

%define variables for recording the results of d and c
Dd=[];
Cc=[];

%initial point
d=0;

while d<=10
    
    %calculate c at given d
    c = 1-1/(1+exp((d-d50)/w));
    
    %record the results
    Dd = [Dd d];
    Cc=[Cc c];
    %update d
    d=d+interval;
end
plot(Dd, Cc, 'b')


achieves the same graph, and it does not seem as though there is any advancement, which i assume there should be as the worksheet progressing, and getting more complex...have i dun something wrong?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us