I have to compile the function but my matrix dimensions are not equal.

clear all close all clc
t=-10:0.1:10; w=input('enter the value of w'); b=input('enter the value for b'); f=zeros(1,length(t));
for i=1:length(t)
f(i)=f+(1./(1+exp(w(i).*t(i)+b(i))));
end

댓글 수: 5

Hi
You are looping over w(i) and b(i). Are they suppose to be vectors or scalars?
Regards, Phillip
They are scalers
If suppose I don't even include them in looping , i am getting again the error which is "??? In an assignment A(I) = B, the number of elements in B and I must be the same. "
I was trying to point out that in the code above w and b are scalars but you are treating them like vectors (w(i) & b(i)) in the for loop.
If they are suppose to be scalars then the answer below is what you are looking for. If not, then you need to be a bit more clear on what the inputs are
I havn't used cumsum function,so therefore I was trying to do through looping. but in looping I am only getting the error of dimensions

댓글을 달려면 로그인하십시오.

답변 (1개)

t = -10:0.1:10;
w = input('enter the value of w = ');
b = input('enter the value for b = ');
f = cumsum(1./( 1 + exp(w*t + b) ));

댓글 수: 2

Thankyou but I want to do it through looping.
Do looping and cumsum bring same ans ?? I havn't used cumsum.. Its commulative sum
f = cumsum(alpha.*(1./( 1 + exp(w*t + b) ))) can i add alpha as multiplier in cumsum function like upper i did????

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2014년 6월 19일

댓글:

2014년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by