Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Pablo001  
#1 Posted : 01 May 2020 10:37:12(UTC)
Pablo001

Rank: Newbie

Groups: Registered
Joined: 23/01/2014(UTC)
Posts: 5
Spain

Dear all,

Thanks for your great help!!

In this sample, when I iterate to find θ, I have no problem at the first time.
test.sm (29kb) downloaded 19 time(s).

Then, when I want to calculate SM matrix, something goes wrong:
- Do you know what is the problem?
- The expression to find θ and SM is the same. Could I use only one expression to calculate these 2 variables?

Then, if y change Cm coefficients in order to find a new θ value, the expression don't work,
- I'm lost


Some feedback?? Thanks in advance!

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Razonar  
#2 Posted : 01 May 2020 12:49:48(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: Pablo001 Go to Quoted Post
Dear all,

Then, when I want to calculate SM matrix, something goes wrong:
- Do you know what is the problem?
- The expression to find θ and SM is the same. Could I use only one expression to calculate these 2 variables?


Hi. Actually I can't find why your code don't works, it looks fine to me. But, some problem have, because the error message. About to use only one expression for both, I guess that this is the solution:

Clipboard07.jpg

Hope this helps.
Best regards.
Alvaro.
Offline hawe  
#3 Posted : 01 May 2020 13:10:54(UTC)
hawe


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2020(UTC)
Posts: 31
Germany
Location: KU

Was thanked: 3 time(s) in 2 post(s)
Originally Posted by: Pablo001 Go to Quoted Post
Dear all,
Then, if y change Cm coefficients in order to find a new θ value, the expression don't work,
- I'm lost



Your first calulation block return theta AND assin it to theta - if your block has finished you have calculated matrizes theta, MM, SM it is not necessary to assin theta again

I think you made a endless loop in the 2. block
make assinments to theta and SM return SM and assign it to itself. Removing the assinment of the blocks.

BTW. what is the difference in calculation SM in 2. block to the one in 1. block?
seems to me SM is ident in both cases


From Newby to Newby ;-)

Start Debugger
1. mark code line
2. set breakpoint
3. start debugger F11
4. continue to breakpoint
5. copy to empty page (better to a 2. instance runing) to examine what you have


SMathDebug_2020-05-01_12-13-52.jpg

Edited by user 01 May 2020 13:27:59(UTC)  | Reason: add debug

thanks 2 users thanked hawe for this useful post.
on 01/05/2020(UTC),  on 01/05/2020(UTC)
Offline Davide Carpi  
#4 Posted : 01 May 2020 14:58:26(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,648
Man
Italy
Location: Italy

Was thanked: 1331 time(s) in 876 post(s)
The error happens because inside the SM procedure (it's a procedure when line is used on the RHS of a variable) you are trying to assign a matrix element to an existing scalar (Θ, defined in the procedure right above). To avoid it, you should initialize the nested variables before using them, f.e. using
Code:
Θ:matrix(rows, columns)
or
Code:
 Clear(θ,...)


If the existing variable θ was already a matrix, you would have ended overwriting the original values without warnings. This is a powerful feature of the program but if you are not aware of it you might end with some crazy results.

In general when you are inside a function or a procedure it's a good practice to always initialize the variables that are meant to be "local"; if you want to inherit a variable and change his value(s) only locally you have to assign it to a local variable. Obviously it can be avoided, if you are aware of the behaviors and you are sure there won't be any accidental inheritance/interference in the worksheet, like for small examples and such.

Edited by user 01 May 2020 15:00:33(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Jean Giraud  
#5 Posted : 01 May 2020 16:23:12(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Pablo001 Go to Quoted Post
Then, if y change Cm coefficients in order to find a new θ value, the expression don't work,
- I'm lost

Best never used the consumed variables
Your 3 data sets from doctored ?

test (4 try this).sm (37kb) downloaded 14 time(s).

Offline Pablo001  
#6 Posted : 01 May 2020 20:37:52(UTC)
Pablo001

Rank: Newbie

Groups: Registered
Joined: 23/01/2014(UTC)
Posts: 5
Spain

Hi,

Thanks everyone for your help!
Understood, it's better to clear the matrix to re-use it.

Jean, your file shows black sentences in my computer.

Jean file
Offline Jean Giraud  
#7 Posted : 01 May 2020 22:30:41(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Pablo001 Go to Quoted Post
Jean, your file shows black sentences in my computer.

That's the mutual freak between 7251 6179 and vice versa.
Select all, background white.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.