Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,652 Location: Italy Was thanked: 1339 time(s) in 878 post(s)
|
Originally Posted by: Alex.M Works great, thank you very much! I almost thought it is not possible hehe. Now I do not quite get how the if() loop works, and why does it work, and why it shall not be equal to -1. Could you walk me through this line of code, explaining what it does exactly? findstr(num2str(id+1),"+" ≠-1 Thanks again, this is very clever and elegant! You're welcome The function uses pass-by-reference to output the value to the canvas via the input argument. If the input value is an unknown, will be set to 1. This should be done in the if/else statement using the built-in ¬IsDefined(id) that for some reason I have to investigate doesn't works, so I've replaced it with findstr(num2str(id+1),"+")≠-1 num2str(id+1) converts the input in a math string -> id+1 will be converted in a number and then in a string if the input argument is a number, otherwise will be "something+1" where something is the name of the input unknown in the canvas (because id is a local name that contains the variable passed from the canvas -> a simple num2str(id)≡"id" is not possible); in the first case, findstr will returns -1, because the string contains a number, in the second case will returns a vector that contains the index of each "+" match. Hence if findstr(...)≠-1 -> the variable is not a number, set it to 1, otherwise increment by one. Originally Posted by: Jean Giraud From Ioan & Davide, it's OK to view image in Smath, but useless as you can't further process/select ... etc. You can "fmap vectorise", scale the grayscale but can't scale RGB replot because Smath does not have the "Picture operator" Jean, I think that both the purposes are OK and can/must coexist If one needs only to show an image on the canvas, there's no need to fill the worksheet memory or the file itself of useless data. If one want/needs to process images, this is another story (BTW, many thanks for all the worksheets you share here in the forum ) IMHO as it is now processing images on the worksheet is reliable only for small images (only teaching purposes); using plugins you can boost the math speed or build a region that can do all "in-place" but this is not funny because the math is hidden under the hood. A "picture operator" or a boost in matrices management is needed and can be done only by Andrey (here we are focusing on images but the issue may be the same in any signal processing problem, such as audio, wind, etc...). The example below is ok for a 128x128 image, but too slow for a 256x256 image (or bigger), using greyscale images, and functions driven in plugin: fftmagnitude (abs() extended to matrices), fftphase (arg() extended to matrices), fftlog (basically a logarithm function for matrices); to run all except the ffts in the canvas (in a reasonable time) 128x128 is too big. Edited by user 25 February 2016 18:18:37(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |