How do I do both, integrate and derive a complex equation in a code using MATLAB App Designer?

5 Ansichten (letzte 30 Tage)
Ok so I am designing an app for a class and the professor wants us to derive and integrate the equation by code. He does not want us to write it down and do it by hand. And well, after redooing the entire code, I am now struggling to find a way on how to derive and integrate the equation within the code in order for the app to function properly. According to MATLAB App Designer, I am getting an error since I have to be getting a possitive integer scalar. However, I have tried using abs command on diff to get a positive answer, but I get the same thing. I tried switching the position of E and Diff(v,e) but I get that E is an unknown variable. I havent eaten breakfast, im hungry, been working on this code since the morning... I am not sure what other thing i can do, I am running out of ideas. I just hope that no other errors pop out after and if I can fix this one. Can some expert on App Designer help me out with this please! I could really use the help! Please Help!

Antworten (1)

Ameer Hamza
Ameer Hamza am 8 Mai 2020
It seems that you are treating diff() and int() as if their inputs are symbolic. However, from your code, it seems that inputs are numeric. You should use gradient() and trapz() to find the numerical derivative and integral
E = gradient(v, e)
a = trapz(e, v)
  4 Kommentare
Tiny Tim
Tiny Tim am 9 Mai 2020
I just found out that all of these were the error... not sure how to fix them...
Ameer Hamza
Ameer Hamza am 9 Mai 2020
Thankfully, it didn't catch an std. It was just a mistake in the testing process xD
The error is just happening because you are using 'e' for indexing. I see no reason for that. Write it like this
u = v;
w = E;
R = a;

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by