Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
matlab
R
Yr=Y;
Us{1}=Yr*C;
U=Us{1};
Fxy=Y-Us{1}*C
R
Yr <- Y
Us <- list()
Us[[1]] <- Yr %*% C
U <- Us[[1]] 
Fxy <- Y-(U[[1]] %*% t(C))


What I have tried:

The U, C, and Y values in the two pieces of code are the same except for the number of digits left after the decimal point. In matlab, four digits are kept, and in R, the calculation is accurate. Y is a 246 2 matrix, C is a 2 1 vector, and U is a 246-row list with dimensions that can be multiplied. Why does it work in matlab and R? Different results
Posted
Updated 11-Dec-23 7:56am
v3
Comments
Richard MacCutchan 10-Dec-23 8:24am    
Since we have no idea what numbers are input and what results you see, it is difficult to make a useful comment.
[no name] 10-Dec-23 13:16pm    
I'd be surprised if they were the same. Implementations are protected; ideas aren't.

1 solution

Have you tried to type "format long" in matlab? What you see in matlab and what is saved might be two different things
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900