在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Q: Suppose I have the following string: s = 'Foo 1.000 3.000 3.554' I would like to read it with the textscan function as follows. [name x y z] = textscan(s, '%s %f %f %f') However, when I do this, I always get the Too many output arguments error. I think it has to do with the fact that textscan outputs a cell array, but I could not discover how to work around this problem and the desired effect. A: You'll need two lines to do what you want. First you get the desired valued into a dummy variable, then distribute the data with deal: dummy = textscan(s, '%s %f %f %f'); Note: After Matlab 7.0, deal() is not neccesary.
Q: i have a file called hello.txt using wordpad which contains the matrix 2 7 3 2 6 9 now i have a vector v = [1 2 3] and i want to add this vector to the hello.txt file so when i open the hello.txt file i should have 2 7 3 2 6 9 1 2 3 how can i do this? A: fid = fopen('hello.txt', 'at'); fprintf(fid, '%d %d %d\n', v); fclose(fid); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论