Profilo di zhenjiezhangKnockOutFotoBlogElenchi Strumenti Guida

KnockOut

21 luglio

Matlab, reading and checking variables in the base workspace from a function

Sorry for throughing shit on my blog...

 

Thread Subject: extract variable from base workspace

Subject: extract variable from base workspace

From: Alan B

Date: 21 May, 2009 22:41:02

Message: 1 of 6

I know I can do
v = evalin('base','var')
to store the value of base workspace variable var into function workspace variable v.

Is there a way to check and be sure that var exists before attempting to assign it? I want this:
v = evalin('base','if exist(var), var, else, defaultVar, end')
but I can't use if/else/end inside the eval. I know I can do this with multiple evals, or try/catch, but is there a way to do it with one eval line?

Subject: extract variable from base workspace

From: Zhelyazko

Date: 22 May, 2009 02:21:01

Message: 2 of 6

This should work;
function f
evalin('base','if exist(''var'',''var'');temp=var; else; temp=defaultVar; end;assignin(''caller'',''v'',temp)')
display(v);

Subject: extract variable from base workspace

From: Alan B

Date: 22 May, 2009 14:51:01

Message: 3 of 6

"Zhelyazko " <ztumbev@yahoo.com> wrote in message <gv526d$m9l$1@fred.mathworks.com>...
> This should work;
> function f
> evalin('base','if exist(''var'',''var'');temp=var; else; temp=defaultVar; end;assignin(''caller'',''v'',temp)')
> display(v);

Thanks, that does work. I am confused though, what exactly are the rules on using if/else/end within an eval? I can do

somevarLocal=evalin('base','somevar');

but not

somevarLocal=evalin('base','if exist(''var'',''var'');temp=var; else; temp=defaultVar; end; temp')

but then your solution does work. This seems contradictory.

Subject: extract variable from base workspace

From: Zhelyazko

Date: 22 May, 2009 20:40:19

Message: 4 of 6

Actually this should work too.
v=evalin('base','eval(''var'',''defaultVar'')');
If you have an output you cannot use if and switch statements

Subject: extract variable from base workspace

From: Alan B

Date: 27 May, 2009 16:39:02

Message: 5 of 6

"Zhelyazko " <ztumbev@yahoo.com> wrote in message <gv72jj$9a8$1@fred.mathworks.com>...
> Actually this should work too.
> v=evalin('base','eval(''var'',''defaultVar'')');
> If you have an output you cannot use if and switch statements

Thanks Zhelyazko, that led me to my solution.

For others who find this in the future:
Both eval and evalin seem to have an (undocumented? I'm using 2006b) extra input argument, which is an eval string to be executed if an error is encountered in the first eval string (including 'undefined variable'). I can use this to do what I was asking with

somevarlocal=evalin('base','somevar','defaultvalue');

Is there more information on valid forms for eval strings somewhere? The documentation doesn't say much. Specifically, it says nothing about not allowing if/switch statements. What else is not allowed, and when?

29 aprile

谈论 notes on cygwin sshd

use double quote to open net share on windows:

net share "sharename=path"

引用

notes on cygwin sshd
03 aprile

notes on cygwin sshd

Notes on enabling SSHD on windows XP:
 
1. install cygwin
2. add windows environmental variable CYGWIN:ntsec tty. add cygwin path to variable $path
3. in bash, run ssh-host-config
4. mkpasswd -l > /etc/passwd
5. mkgroup -l > /etc/group
 
You may also need to (happened on my laptop):
chmod +r /etc/passwd
chmod +r /etc/group
chmod 755 /var
chmod 744 /var/empty
 
run the service by:
net start sshd or /usr/sbin/sshd (use -d for debug mode)
 
sshd will be bound to 0.0.0.0:22 (check with netstat -an). If want to bind to a specific interface, edit /etc/ssh_config
 
test the server by: ssh -vvv localhost or telnet localhost 22
 
Enable port 22 on your firewall. For NAV, go to client firewall->configure->advanced->general->add...
Important: After adding the firewall rule, move it up to the top of the list, otherwise it may fail.
 
One problem:
windows disk c:\ is automatically mounted to /cygdrive/c with full privileges granted to all users...I was unable to hide it. It should be a problem rooted in the privilege management of windows. Any one has ideas?
 
 
 
22 febbraio

清蒸东星斑

今天在大华见到几条鲜红的星斑鱼,巨口细鳞,倒有点像坡老的“松江之鲈”。想这厮看上去肥美嫩滑,真用对付松鲈的方法清蒸一下,应该不差。

于是添柴升火,点碟配盘。先用牛肉烧一口汤,撇去血沫,微火待用。同时去鱼鳞鱼肠鱼腮,两面各划三刀,深可至骨,用黄酒、酱油调少许醋抹洒,要浸透鱼身划口。放置一刻钟,上蒸笼大火蒸透,一斤半鱼十二至十五分钟就好。蒸锅中水须事先烧开,不可以蒸得太久,太久就会老。蒸法要以鱼背朝下,鱼腹仰开,可盛以调味,木耳等。蒸完装盘。别取一碗放盐,倒入牛肉汤调好,再把碗中牛肉浇到盘中鱼身,作为汤汁。然后细切葱花,蒜片,撒在鱼身鱼腹,再烧开一锅底精油,自头至尾淋上一遍,则葱香鱼香扑鼻,并且色泽鲜亮,入口有由微焦至极嫩的层次感。  

DSC_3144

DSC_3147

 今天最好吃的菜是LD大人的五湖香酥红烧大虾,不过做法珍贵,是不传之秘,就只传图一张,以为我小博增辉:DSC_3153

17 agosto

Gungeness

LD来了,这次是无限期视察(献花)。鉴于食品的消耗速度,这礼拜多去了好几趟菜场。周四搞回来一个邓吉尼斯大脚蟹,两斤多点,毛手毛脚地蒸上吃掉,还下了点小酒。夜色很快降临,似乎比平时还要早很多。这里有古越龙山,三块多,还有茅台,也并不贵。从前上学时读过“红酥手,黄籘酒”,这“红酥”两个字,用来形容螃蟹和黄酒,其实再合适不过了。
 
效果图:
 
有些东西,煮熟了还蛮威风的:
 
合个影:
 
临别纪念:
 
按照老娘的授意,就这么把无肠兄活煮了。前代无聊文人笔记里的说法,大略螃蟹都是坏蛋投胎,是天意如此,要受这种刑罚。原来我们舟山岛上的老乡们,天天都在如此惬意地替天行道啊。
18 luglio

MS Word table of content template

The template "Formal" f**ks the font size up if you have both upper and lower cases in your text. It has burned my ass today. So be cautious.
16 giugno

Fixing missing columns in Endnote X1

I installed endnote X1 recently. When importing RIS format citations from ScienceDirect, the informations of "authors" and "title" and "journal" were always missing. Really annoying. Finally figured out why: I had an old version of endnote 7 on the computer, and somehow endnote X1 was using the filters in the endnote 7 folder. Simple solution: go to "edit"->"preferences"->"folder locations" and click "use endnote defaults". Things are working correctly now. Other people may experience the same problem, hope it helps.
 
Foto 1 di 3