rtod() not working as expected. Possible misuse? - iphone

I am using DDMathParser in my application but I do not understand how to use the function rtod(). I have tried multiple equations but it does not seem to be working.
Some equations do work ex. rtod(acos(0)). But others are not rtod(sin(50)).
Here is an example of the test I did:
> rtod(acos(0))
rtod(acos(0)) = 90
> rtod(sin(50))
rtod(sin(50)) = -15.03297176759753
>
Is it the fact that I am misusing it? I'm not quite sure. But i'm pretty sure that it works someway, for I downloaded an application with DDMathParser built in and there's works just fine.
Hope someone can help!

sin(50) is not the same as sin(50 degrees) because it's decimal (values go up to tenths).
You're feeding in decimals which the trigonometric functions see as radians.
sin(rtod(50))
Try it like that.
rtod(50) = 0.872664626 radians
sin(0.872664626) = 0.766044443

Related

How to fill tables in powerpoint from a cell array in matlab?

I've downloaded saveppt2, jrichter's code and even WritetoWordfromMatlab and tried reading through them to figure it out with no luck. I have something of my own built already so I just need to figure out how to get tables to work.
Whenever I try something like:
myTable.Cell(1,1).TextFrame.Text = 'textstring'
or
myTable.Table.Cell(1,1) = 'textstring'
Or any combination of table / text commands I end up with there being no such property or function as cell for table objects. Every COM/VBA/C library I can find, as well as some code in Python (PandastoPowerPoint from Github) that does what I'm aiming to do says that Table.Cell(row,col) should work. Is this specifically a problem with matlab trying to use (#,#) as a form of indexing?
Try
myTable.Cell(1, 1).Shape.TextFrame.TextRange.Text = "TextString"
or = 'TextString' if that's what matlab prefers.
Thanks Steve R! With a little tweak, I got it to work, finally. So here's the answer:
% add table to existing slide object
myTable = slide.Shapes.addTable(nRows,nCols,x0,y0,rowWidthnRows,colHeightnCols)
myTable.Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = 'TextString'

GAMS: retrieve information from solution

GAMS: I think I have a pretty simple question, however I'm stuck and was wondering if someone could help here.
A simplified version of my model looks like this:
set(i,t) ;
parameter price
D;
variable p(i,t)
e(i,t);
equations
Equation1
obj.. C=sum((i,t), p(i,t)*price);
Model file /all/ ;
Solve file minimizing C using MIP ;
Display C.l;
p(i,t) and e(i,t) are related:
Equation1 .. e(i,t)=e=e(i,t-1)+p(i,t)*D
Now I want to retrieve information from the solution: lets say I want to know at what t e(i,t) has a certain value for example --> e(i,t)= x(i) or otherwise formulated e(i,t=TD)=x(i) find TD, where x(i) thus is depending on i. Does anyone know how I can write this in to my GAMs model? To be clear I do not want to change anything about my solution and the model I have runs; I just want to retrieve this information from the solution given.
So far I tried a couple of thing and nothing worked. I think that this must be simple, can anyone help? Thank you!
Try something like this:
set i /i1*i10/
t /t1*t10/;
variable e(i,t);
*some random dummy "solution"
e.l(i,t) = uniformInt(1,10);
set find5(i,t) 'find all combinations of i and t for which e.l=5';
find5(i,t)$(e.l(i,t)=5) = yes;
display e.l,find5;
Hope that helps,
Lutz

Adjusted box plot in R

I was wandering if someone knows a package for adjusted box plot.
I want for example to draw this boxplot(age~groupe+sexe+other_variables)
Thanks in advance,
Peter
Can't believe my answer was deleted. I don't know much about the stackoverflow rules, I don't know much about R (only studied r for 2 days), and I don't know much English even. I just happened to know this, and I was trying to help, since I've got lot help from the web. Let's try again.
I was wandering if someone knows a package for adjusted box plot.
Yes. There's a package named robustbase in r. And specifically the `adjbox()' fun in the package.
I want for example to draw this boxplot(age~groupe+sexe+other_variables)
Well, this is not a question. He meaned he wanted to do something, not he wanted examples, right (help my poor English)? Anyway you can draw an adjusted boxplot mainly like adjbox(age~groupe+sexe+other_variables)
Part of docstring of the func is as following:
adjbox(x, ..., range = 1.5, width = NULL, varwidth = FALSE,
notch = FALSE, outline = TRUE, names, plot = TRUE,
border = par("fg"), col = NULL, log = "",
pars = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5),
horizontal = FALSE, add = FALSE, at = NULL)
As for more details, you can try help(adjbox) in R, I think.
Here is some documents about the fuc arguments, and about the package.
Though I think "Yes, there's a func called adjbox in a package called robustbase in R can do that" was pretty enough to answer the question, especially for an R user, because R is well knowned as its good self documenting packages. And I don't think a long answer is gonna do more help. But still I'm trying to give a better answer. If somebody has a better answer, then answer. If somebody can modify my answer to be better, I'm fine with that Or if anybody can help me, I'm open to it, because I do actually need help on R and on English. But by just deleting the only answer isn't gonna help more. After all, I wasn't like asking for any voting, or demanding mine to be the best answer, or prevending others to answer it. Nor am I delivering wrong information.
There is a function named adjbox in the package robustbase.
As for the document for adjbox: http://svitsrv25.epfl.ch/R-doc/library/robustbase/html/adjbox.html
And the document for the robustbase: http://cran.r-project.org/web/packages/robustbase/robustbase.pdf

Debugging a for loop in matlab

I've been looking throught the documentation, but can't seem to find the bit I want.
I have a for loop and I would like to be able to view every value in the for loop.
for example here is a part of my code:
for d = 1 : nb
%for loop performs blade by blade averaging and produces a column vector
for cc = navg : length(atbmat);
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg;
atbvec2(:,cc) = atb2;
end
%assigns column vector 'atbvec2' to the correct column of the matrix 'atbmat2'
atbmat2(d,1:length(atbvec2)) = atbvec2;
end
I would like to view every value of atb2. I'm a python user(new to MATLAB) and would normally use a simple print statement to find this.
I'm sure there is a way to do it, but I can't quite find how.
Thankyou in advance.
you can use disp in Matlab to print to the screen but you might want to use sprintf first to format it nicely. However for debugging you're better off using a break point and then inspect the variable in the workspace browser graphically. To me, this is one of Matlab's best features.
Have a look at the "Examine Values" section of this article
The simplest way to view it everywhere is to change this line:
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg;
Into this, without semicolon:
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg
That being said, given the nature of your calculation, you could get the information you need as well by simply storing every value of abt2 and observing them afterwards. This may be done in atbmat2 already?
If you want to look at each value at the time it happens, consider setting a breakpoint or conditional breakpoint after the line where abt2 is assigned.

Extraction of specific numbers

If a string has just a combination of 1(s) and 2(s) how do you extract all the 2(s).
I have tried this code below but does not work.
C=textscan(trigs,'%2d.',2);
Could someone point me in the right direction
You can obtain the position of all the 2's like this:
str = '11221212';
strfind(str,'2')
What? Just find the location of the elements in str with a '2' in it? I don't think you tried that hard, since there are at least a few ways I can see off the top of my head.
C = find(str == '2');
Or,
C = strfind(str,'2');
(There is also findstr, but that tool will apparently be obsolete/dropped at some point.)
Or,
C = regexp(str,'2')
Or,
C = find(ismember(str,'2'));
I'll bet there are lots more ways too. Take a glance through the output of this:
help strfun