How to replace/modify something in a call to function 1 from within function 2 (both in their separate files)

BoroBorooooooooooooooooooooooo

The given task is to call a function from within another function, where both functions are handling matrices.

Now lets call this function 1 which is in its own file:

A = (1/dot(v,v))*(Ps'*Ps);

Function 1 is called with the command:

bpt = matok(P);

Now in another file in the same folder where function 1 is located (matok.m) we make another file containing function 2 that calls function 1:

bpt = matok(P);

What I wish B to do technically, is to return the result of the following (where D is a diagonal matrix):

IGNORE THIS LINE: B = (1/dot(v,v))*(Ps'*inv(D)*Ps*inv(D);

EDIT: this is the correct B = (1/dot(v,v))*(Ps*inv(D))'*Ps*inv(D);

But B should not "re-code" what has allready been written in function 1, the challenge/task is to call function 1 within function 2, and within function 2 we use the output of function 1 to end up with the result that B gives us. Also cause in the matrix world, AB is not equal to BA, then I can't simply multiply with inv(D) twice in the end. Now since Im not allowed to write B as is shown above, I was thinking of replacing (without altering function 1, doing the manipulation within function 2):

(Ps'*Ps)

with

(Ps'*inv(D)*Ps*inv(D)

which in some way I imagine should be possible, but since Im new to Matlab have no idea how to do or where even to start. Any ideas on how to achieve the desired result?

A small detail I missed:

The transpose shouldn't be of Ps in this:

B = (1/dot(v,v))*(Ps'*inv(D))*Ps*inv(D);

But rather the transpose of Ps and inv(D):

B = (1/dot(v,v))*(Ps*inv(D))'*Ps*inv(D);

I found this solution, but it might not be as compressed as it could've been and it seems a bit unelegant in my eyes, maybe there is an even shorter way?:

C = pinv(Ps') * A
E = (Ps*inv(D))' * C
G.J

Since (A*B)' = B'*A', you probably just need to call

matok(inv(D) * Ps)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to call a function from within another function?

How to return the value of function 2 from within function 1

How to call dropzone processQueue() from separate function?

How to call struct from separate function?

How to call a function from a separate .cpp file?

How to call a function within a function from another function in Python?

How to call a function from an object within a class?

How to call reloadData() from within protocol function

How to call a JavaScript function from within Selenium?

How to call bash function from within awk?

How to call variable from within a function

Call a function within a function display both within array

How to call a list from a function within a Kivy GUI class to a function within another within Kivy GUI class? Both classes are in the same .py file

How to call function within a function

How to call a function within a function?

Is it possible to call one function from another? (keeping separate files)

How to execute something similar to a goto statement in node js or how to create and call a function within an asynchronous function?

How can I call on a variable within a function, from outside of that function?

How to call a function's methods from within another function

How do I call a function from within a nested function in typescript?

How do I call my function from within my function?

How to call this.function from inside another function within Vue

How to call a function nested within within a promise from the controller?

how to call function that is in window1 from window2

How to call a function in another function in order to change something in the 1. function

call a function from within eventListener

Call function from within dictionary

How to call WordPress function from other files

is there something equivalent to "cudaMemcpy" from device global memory to host global memory that I can call within a device function?